Expand description
Serialization and Deserialization library for Elektron Octatrack data files.
§Important types
| rust type | octatrack filename pattern | description |
|---|---|---|
| crate::arrangements::ArrangementFile | arr??.* | data for arrangements |
| crate::banks::BankFile | bank??.* | data for parts and patterns |
| crate::markers::MarkersFile | markers.* | start trim/end trim/slices/loop points for sample slots |
| crate::projects::ProjectFile | project.* | project level settings; state; sample slots |
| crate::samples::SampleAttributes | *.ot | saved sample settings data, loops slices etc. |
Only the above types implement the crate::Encode and crate::Decode traits, which means only these types can be read from / written to the filesystem using functions in this library.
Read the relevant modules in this library for more detailed information on the data contained in each file.
§How do different Octatrack data files relate to each other?
- A Bank stores zero-indexed sample slot IDs to indicate which sample should be played when on a given track (part machine data and/or track p-lock trigs).
- Changing the sample loaded into a sample slot updates both the
project.*file (change the trig quantization settings, file path etc) and themarkers.*file (change the trim settings based on either initial load, or any data in a relevant*.otsample settings file). - Data from
project.*andmarkers.*is written to an*.otfile when saving sample attributes data from the octatrack’s audio editing menu. - Loading a sample into a project sample slot (
project.*andmarkers.*files) reads any data in an*.otfiles and configures the sample slot accordingly.
§When do *.work and *.strd files get modified by the Octatrack?
*.workfiles are created when creating a new projectPROJECT MENU -> CHANGE PROJECT -> CREATE NEW.*.workfiles are updated by using thePROJECT MENU -> SYNC TO CARDoperation.*.workfiles are updated when the user performs aPROJECT MENU -> SAVE PROJECToperation.*.strdfiles are created/updated when the user performs aPROJECT MENU -> SAVE PROJECToperation.*.strdfiles are not changed by thePROJECT -> SYNC TO CARDoperation.arr??.strdfiles can also be saved via theARRANGER MENU -> SAVE ARRANGEMENToperation.
§Notable ’gotcha’s
- Project sample slots (
project.*files) are one-indexed, but their references everywhere else are zero-indexed (bank??.*andmarkers.*files). - A ‘Disabled’ loop point in either
markers.*or*.otfiles is a0xFFFFFFFFvalue, but the default loop point when creating newmarkers.*file is always0_u32. The ‘Disabled’ value setting is only set when a sample is loaded into a sample slot.
§Example code
/*
reading, mutating and writing a bank file
*/
use std::path::PathBuf;
use ot_tools_io::{read_type_from_bin_file, write_type_to_bin_file, banks::BankFile};
let binfpath = PathBuf::from("test-data")
.join("blank-project")
.join("bank01.work");
// read an editable version of the bank file
let mut bank: BankFile = read_type_from_bin_file(&binfpath).unwrap();
// change active scenes on the working copy of Part 4
bank.parts.unsaved[3].active_scenes.scene_a = 2;
bank.parts.unsaved[3].active_scenes.scene_b = 6;
// write to a new bank file
let outfpath = std::env::temp_dir()
.join("ot-tools-io")
.join("doctest")
.join("main_example_1");
write_type_to_bin_file::<BankFile>(&bank, &outfpath).unwrap();Modules§
- arrangements
- Types and ser/de for
arr??.*binary data files. - banks
- Types for
bank??.*binary data files. - markers
- Types and ser/de of
markers.*binary data files. - projects
- Types and ser/de of
project.*data files. - samples
- Types and ser/de of
*.otbinary data files.
Enums§
- OtTools
IoErrors - Global error variants
Traits§
- Calculate
Checksum - Method for calculating the checksum value for types that have a checksum field
- Check
Checksum - Adds a method to verify if checksum is valid in some data type. See this thread to understand why this is useful: https://www.elektronauts.com/t/bank-unavailable-octatrack/190647/27
- Check
Header - Adds a method to verify if header(s) are valid in some data. See this thread to understand why this is useful: https://www.elektronauts.com/t/bank-unavailable-octatrack/190647/27
- Check
Integrity - Adds a single method using the crate::CheckHeader and crate::CheckChecksum methods to run a full integrity check.
- Decode
- Adds deserialisation via
bincodeandserdeto a type. Must be present on all major file types. - Defaults
Array - Used when we need a collection of default type instances e.g. when creating a default bank we need 16 default patterns.
- Defaults
Array Boxed - Same as
DefaultsArray, but using a boxed serde_big_array::Array container type - Encode
- Adds serialisation via
bincodeandserdeto a type. Must be present on all major file types. - IsDefault
- Adds a method to check the current data structure matches the default for the type
Functions§
- bin_
file_ to_ json_ file - Read data of type
<T>from a binary data file and write it to a JSON file - bin_
file_ to_ yaml_ file - Read data of type
<T>from a binary data file and write it to a YAML file - default_
type_ to_ bin_ file - Create a new type with default settings, and write the data to a file.
- deserialize_
bin_ to_ type - Deserialize a bytes to a data structure of type
T - deserialize_
json_ to_ type - Deserialize a JSON string to a data structure of type
T - deserialize_
yaml_ to_ type - Deserialize a YAML string to a data structure of type
T - json_
file_ to_ bin_ file - Read a JSON file then write the data to a new
<T>type file - json_
file_ to_ type - Read a JSON file into a data structure of type
<T> - read_
bin_ file - Read bytes from a file at
path. - read_
str_ file - Read a file at
pathas a string. - read_
type_ from_ bin_ file - Read a data structure of type
<T>from a binary data file. - serialize_
bin_ from_ type - Serialize to bytes from a data structure of type
T - serialize_
json_ from_ type - Serialize a JSON string from a data structure of type
T - serialize_
yaml_ from_ type - Serialize a YAML string from a data structure of type
T - show_
type - Show deserialized representation of a binary data file of type
Tatpath - type_
to_ json_ file - Write a data structure of type
<T>into a JSON file - type_
to_ yaml_ file - Write a data structure of type
<T>into a YAML file - write_
bin_ file - Write bytes to a file at
path. - write_
str_ file - Write a string to a file at
path. - write_
type_ to_ bin_ file - Write a data structue of type
<T>to a binary data file. - yaml_
file_ to_ bin_ file - Read a YAML file then write the data to a new
<T>type file - yaml_
file_ to_ type - Read a YAML file into a data structure of type
<T>