Skip to content

Commit

Permalink
Fixed WAV length+speed for fmt v7
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnfrishert committed Sep 13, 2018
1 parent 2cf2b77 commit 8fc434c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions liblsdj/instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,15 @@ void read_wave_instrument(lsdj_vio_t* vio, unsigned char version, lsdj_instrumen
instrument->wave.playback = parsePlaybackMode(byte);

// WAVE length and speed changed in version 6
if (version >= 6)
if (version >= 7)
{
vio->read(&byte, 1, vio->user_data); // Byte 10
instrument->wave.length = 0xF - (byte & 0xF);

vio->read(&byte, 1, vio->user_data); // Byte 11
instrument->wave.speed = byte + 4;
}
else if (version == 6)
{
vio->read(&byte, 1, vio->user_data); // Byte 10
instrument->wave.length = (byte & 0xF);
Expand Down Expand Up @@ -712,7 +720,15 @@ void write_wave_instrument(const lsdj_instrument_t* instrument, unsigned char ve
byte = createPlaybackModeByte(instrument->wave.playback);
vio->write(&byte, 1, vio->user_data);

if (version >= 6)
if (version >= 7)
{
byte = 0xF - (instrument->wave.length & 0xF);
vio->write(&byte, 1, vio->user_data);

byte = instrument->wave.speed - 4;
vio->write(&byte, 1, vio->user_data);
}
else if (version == 6)
{
byte = (instrument->wave.length & 0xF);
vio->write(&byte, 1, vio->user_data);
Expand Down

0 comments on commit 8fc434c

Please sign in to comment.