Crate m8_files

Source
Expand description

This library lets you parse Dirtywave M8 data

See, in particular, the read method available on:

E.g.:

use m8_files::*;

let mut f = std::fs::File::open("./examples/songs/TEST-FILE.m8s").unwrap();
let song = Song::read(&mut f).unwrap();
dbg!(song);

For song writing and file manipulation, you will need to load the whole file in memory, in order to be able to overwrite it

use m8_files::*;
use m8_files::remapper::Remapper;
let mut song_data = std::fs::read("./examples/songs/V4EMPTY.m8s").unwrap();
let mut song_reader = reader::Reader::new(song_data.clone());
let mut song = Song::read_from_reader(&mut song_reader).unwrap();

// let's renumber an instrument
let mut remapper = Remapper::default_ver(song.version);
let instrument : usize = 4;
let to_instrument = 10;
remapper.instrument_mapping.mapping[instrument] = to_instrument;
remapper.instrument_mapping.to_move.push(instrument as u8);
remapper.renumber(&mut song);

dbg!(&song);

let mut output_writer = writer::Writer::new(song_data);

song.write(&mut output_writer);
// ready to be written elsewhere
let output_song_data = output_writer.finish();

You also can perform more complex copies of chain, that will copy intrument/eq/table definitions required to copy a chain from a song to another

use m8_files::*;
use m8_files::remapper::Remapper;

let mut from_file = std::fs::File::open("./examples/songs/TEST-FILE.m8s").unwrap();
let from_song = Song::read(&mut from_file).unwrap();
let mut empty_file = std::fs::File::open("./examples/songs/V4EMPTY.m8s").unwrap();
let mut to_song = Song::read(&mut empty_file).unwrap();
let chain : u8 = 12;
let mapping =
    Remapper::create(&from_song, &to_song, vec![chain].iter()).unwrap();
// you can inspec the mapping here if needed.
// and apply the remapping
mapping.apply(&from_song, &mut to_song);
// you now have the chain 12 in to_song, and you can edit a song
// cell to write it
let final_chain = mapping.out_chain(chain);
to_song.song.steps[2] = final_chain;

Modules§

reader
remapper
writer

Structs§

ADSREnv
AHDEnv
Chain
ChainStep
CommandPack
This structure will aggregate for every instrument and its modulator the name of the commands associated to it.
ControlChange
DrumEnv
EffectsSettings
ExternalInst
FMSynth
FX
FmAlgo
FxCommands
Groove
HyperSynth
InputMixerSettings
InstrumentWithEq
Firmware 4.1 introduce files with an instrument definition and an EQ. This structure represent the result of parsing such insturment with an optional EQ.
LFO
LimitType
MIDIOut
MacroSynth
MidiMapping
MidiSettings
MixerSettings
Note
NoteOffset
Offsets
Operator
Phrase
PhraseView
RGB
Sampler
Scale
Song
MARK: Song
SongSteps
Step
SynthParams
Table
TableStep
TableView
Theme
TrackingEnv
TrigEnv
Version
WavSynth

Enums§

AnalogInputSettings
FMWave
Instrument
LfoShape
LfoTriggerMode
MacroSynthOsc
Macro synth oscilator modes.
Mod
SamplePlayMode
WavShape
Wavsynth wave shape

Constants§

V4_1_OFFSETS
V4_OFFSETS