Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing CMF Notes #41

Open
ghost opened this issue Oct 14, 2016 · 10 comments
Open

Missing CMF Notes #41

ghost opened this issue Oct 14, 2016 · 10 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Oct 14, 2016

There are notes missing on CMF playback. I think it could be to do with the number of instruments (and so could potentially be an easy fix, I hope). @Malvineous, what do you think?

Attached is an example of a file from the game Xargon. Included are the CMF file and two different recordings of it (one through ADPlug and one converted with a CMF Tool several years back). You'll notice that the bass notes are consistent throughout the CMF Tool's output, whereas ADPlug skips over some of them (leaving spaces).

Here's an example: example.zip

@Malvineous
Copy link
Member

Very interesting! I had noticed this but not actually checked how the original sounded. With Creative Labs' SBFMDRV the notes are also present, so since that's the gold standard for CMF playback, this is definitely a bug. Both AdPlug and my own libgamemusic are missing the notes.

However, listing the song's events with libgamemusic reveals something interesting:

$ gamemus example_original.cmf --list-events
Opening example_original.cmf as type <autodetect>
File is definitely: Creative Labs Music File [cmf-creativelabs]
Song has 1 patterns
>> Pattern 0, track 0
0: delay=0;event=config;type=enableOPL3;value=1
1: delay=0;event=config;type=enableDeepTremolo;value=1
2: delay=0;event=config;type=enableDeepVibrato;value=1
3: delay=0;event=config;type=enableWaveSel;value=1
4: delay=0;event=config;type=enableRhythm;value=1
5: delay=0;event=note-on;freq=220000;freq_midi=57;freq_oct=4;instrument=0;velocity=255
6: delay=21;event=note-off
7: delay=0;event=note-on;freq=220000;freq_midi=57;freq_oct=4;instrument=0;velocity=255
8: delay=21;event=note-off
9: delay=0;event=note-on;freq=220000;freq_midi=57;freq_oct=4;instrument=0;velocity=255
10: delay=21;event=note-off
11: delay=43;event=note-on;freq=164813;freq_midi=51.9999;freq_oct=4;instrument=0;velocity=255
12: delay=21;event=note-off
13: delay=0;event=note-on;freq=164813;freq_midi=51.9999;freq_oct=4;instrument=0;velocity=255
14: delay=22;event=note-off
15: delay=0;event=note-on;freq=174614;freq_midi=53;freq_oct=4;instrument=0;velocity=255
16: delay=21;event=note-off
17: delay=0;event=note-on;freq=174614;freq_midi=53;freq_oct=4;instrument=0;velocity=255
18: delay=0;event=note-off
19: delay=21;event=note-on;freq=174614;freq_midi=53;freq_oct=4;instrument=0;velocity=255
20: delay=22;event=note-off
21: delay=0;event=note-on;freq=174614;freq_midi=53;freq_oct=4;instrument=0;velocity=255
22: delay=21;event=note-off
23: delay=0;event=note-on;freq=146832;freq_midi=50;freq_oct=4;instrument=0;velocity=255
24: delay=21;event=note-off
25: delay=0;event=note-on;freq=146832;freq_midi=50;freq_oct=4;instrument=0;velocity=255
26: delay=0;event=note-off

If you look at the last two events (25 and 26) you can see that there is no delay between the note-on (25) and the note-off (26). The note-off is supposed to happen at the same instant as the note-on. The other notes all have a delay (e.g. event 24 has a delay of 21 ticks before the note is silenced.)

So technically AdPlug is playing the song correctly! I will have to investigate further as I am not sure whether the solution is to force a delay of at least one tick between note on/off events, or whether that particular instrument will sound even if triggered for only a brief instant - it's possible as of now that it is switched off again before the OPL emulator has noticed it has been switched on, but running the emulator callback at least once between events may be enough for the note to sound in the OPL "release" phase even if switched off immediately.

@binarymaster
Copy link
Member

binarymaster commented Nov 4, 2016

PR #44 should solve this issue. Please check whether it affect on other songs playback somehow.

This is not related to delays at all, the problem is in the interpreting such event sequence:

Chn | Event    | Data
  1 | Note On  | E4, 127
  1 | Note Off | E4, 0
  1 | Note On  | F4, 127  <- normal note on
  1 | Note On  | F4, 127  <- duplicate, should turn note off
  1 | Note Off | F4, 0    <- fix previous, turn note on
  1 | Note Off | F4, 0    <- normal note off
  1 | Note On  | F4, 127
  1 | Note Off | F4, 0

@ghost
Copy link
Author

ghost commented Nov 5, 2016

I'd happily do some thorough testing if you could provide a build of the Winamp plugin with this patch applied (as I'm unable to compile it myself at this point in time).

@binarymaster
Copy link
Member

@thecoreyburton here you go: in_adlib.zip

@ghost
Copy link
Author

ghost commented Nov 5, 2016

Thank you!

I've only done some quick testing as I'm out and about at the moment but as far as I can tell this has resolved the issue. Any notes that were absent in comparison of the Xargon soundtrack between SBFMDRV and ADPlug seem to be fixed, though this was only on a simultaneous play-through of pre-rendered .wav output. I'll have a proper, less subjective look a bit later on but so far so good!

@binarymaster
Copy link
Member

I have noticed another difference: the lead/pad voice has no chorus-like effect in AdPlug, so the same voice sounds better using SBFMDRV driver. But this is for another issue.

@ghost
Copy link
Author

ghost commented Nov 5, 2016

I'll create it now, I noticed an unrelated missing effect as well and had planned on bringing it up in a separate issue anyway.

@binarymaster
Copy link
Member

Temporary quick-fix is committed in 4f7d41e.

Leaving the issue open for a proper fix.

@mywave82
Copy link
Contributor

mywave82 commented Feb 7, 2024

If you look at the last two events (25 and 26) you can see that there is no delay between the note-on (25) and the note-off (26). The note-off is supposed to happen at the same instant as the note-on. The other notes all have a delay (e.g. event 24 has a delay of 21 ticks before the note is silenced.)

That would be up to how the ADSR (Attack-Delay-Sustain-Release) logic is implemented. Handling should be implemented to follow what the original CMF software did, even for this "broken" corner-case.

@viiri
Copy link

viiri commented Apr 10, 2024

https://github.com/viiri/fmdrv - CMF player based on disassemled SBFMDRV.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants