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

Channel 3 Midi export is missing notes #19

Closed
Wapata opened this issue Dec 20, 2018 · 12 comments
Closed

Channel 3 Midi export is missing notes #19

Wapata opened this issue Dec 20, 2018 · 12 comments

Comments

@Wapata
Copy link

Wapata commented Dec 20, 2018

Hi everyone !
When I use this command "gbsplay -o midi myfile.gbs" the result is a midi file per song.
This is fine.
But there is not 4 midi instruments in each midi file, as result, I can't read the partition of the bass line, the solo, the chords... And it doesn't sound like when I use this command "gbsplay myfile.gbs".

(I hope my English here is good enough to be read)

Thanks for the attention.

@Wapata
Copy link
Author

Wapata commented Dec 20, 2018

Hi. More informations:
Midi Channel 2 seem okay
Midi Channel 3 is empty
Midi Channel 4 is not created (but it's okay as it's drum's)
Midi Channel 1 seem to have channel 1 and 3 merged

@mmitch
Copy link
Owner

mmitch commented Dec 21, 2018

Which GBS file are you converting?

When I run ./gbsplay -T 120 -o midi examples/nightmode.gbs I get a gbsplay-1.mid that visually looks like it contains the 3 exported voices on 3 different midi channels (I don't currently have a proper setup, so I can only look but not hear).

If your GBS file uses channel hacks to play two voices simultaneously on a single channel, then the export will also contain these two voices on a single channel. Mixing multiple voices on a single channel is a common technique to overcome the Gameboy hardware limitation of 4 channels.

I don't know if if would be possible to disentagle multiple voices on a channel by looking at the current waveform - this will most certainly break other things where there is only 1 intended voice on a single channel.

@Wapata
Copy link
Author

Wapata commented Dec 21, 2018

It's the Smurf (the first one) and... It may use channel hack... When I mute all but 1 channel, the sound represent the bass line and some chord.
I'll try to make a video of it when I go back to my computer.
And I will test nightmode too.

Side note: I'm very happy that you still be here !

@mmitch
Copy link
Owner

mmitch commented Dec 21, 2018

I've had a look at the Smurfs, subtune 1:

  1. Channel 1 contains base and arpeggio, like you said. Depending on your MIDI editor, you might be able to split the channel into two by selecting everything lower than F2 as bass (apart from the first 3 bars).
  2. After looking at the register description of the sound chip, I don't think gbsplay itself can properly split channels with multiple voices. One could experiment with splitting by the duty register (eg. channel 1 becomes MIDI tracks 1-4 and channel 2 becomes 5-8), I'd be interested in what comes out of that.
  3. Track 3 is not completely empty. It does contains some events starting in bar 3, but they don't resemble anything close to what gbsplay is displaying on the channel when running. This looks like some kind of bug to me.
  4. At least track 1 also uses some kind of echo: Notes are retriggered with a lower volume. In the MIDI output, this makes for duplicate notes. Again, depending on your MIDI editor, you might be able to filter out the echoes based on some condition like volume < 100.

@mmitch
Copy link
Owner

mmitch commented Dec 23, 2018

I have updated the manpages to describe the current limitations of the MIDI export:

gbsplay/man/gbsplay.in.1

Lines 179 to 193 in 8a6b509

.B midi
Write a simple MIDI conversion of the song
into a seperate file per subsong.
The files are called \fIgbsplay-%d.mid\fP,
where \fI%d\fP is replaced with the subsong number.
The files are created in the current working directory
and existing files are silently overwritten.
Only channels 1 to 3 are converted to MIDI,
because channel 4 contains noise data
that can't be converted into MIDI note events.
Every GBS channel is exported to a seperate MIDI channel.
When multiple voices share a channel,
they will not be separated in the output.
The conversion is rather basic and complicated GBS files
using tricks and hacks will not be converted properly.

The track 3 issue still remains. I have had a look at some other .GBS files and sometimes track 3 looks ok, sometimes not. Sometimes this changes even within a GBS: some subsongs are ok, others are not.

I don't know whether this is a genuine bug in the MIDI export code or if channel 3 is just more complicated to export. Technically channel 3 (wave) is quite different from channels 1 and 2 (square).

@Wapata
Copy link
Author

Wapata commented Dec 23, 2018

Thanks a lot for the investigation !
The weirdest thing is that the notes seem exact on screen :-/
Is it possible to slow down the songs by the way ?
I have a trick to propose for the channel 4. But it's not an issue so I will write it in the good place. ;-)

@mmitch mmitch added bug and removed question labels Dec 23, 2018
@mmitch
Copy link
Owner

mmitch commented Dec 23, 2018

I have indeed found something:

  • triggering a note did not take the global DAC into account
  • changing volume to or from zero did not start/stop notes

It looks much better now. I'll have to make a proper fix out of this over the next days.

Also I will try to take the length counter into account - it's currently missing, but does not seem to have a deep impact on the export.

@mmitch mmitch changed the title Midi file is a mess Channel 3 Midi export file is missing notes Dec 23, 2018
@mmitch mmitch changed the title Channel 3 Midi export file is missing notes Channel 3 Midi export missing notes Dec 23, 2018
@mmitch mmitch changed the title Channel 3 Midi export missing notes Channel 3 Midi export is missing notes Dec 23, 2018
@mmitch
Copy link
Owner

mmitch commented Dec 25, 2018

I have pushed some changes yesterday.
75a2044 should fix channel 3 in the MIDI export on The Smurfs.
Could you try it?

@Wapata
Copy link
Author

Wapata commented Dec 25, 2018

Yes I will !
Maybe tomorrow ;-)

@mmitch
Copy link
Owner

mmitch commented Nov 9, 2020

@Wapata has the issue been solved for you?

@Wapata
Copy link
Author

Wapata commented Nov 10, 2020

Well... I don't know 0-o. I... I don't think so, but it's been two years ! You've made an update to gbsplay ?
My time have been consumed by my kid, so I didn't update the software to test. I don't know if I can test it this month, but did you try it by your side ?

@mmitch
Copy link
Owner

mmitch commented Nov 10, 2020

I did test in 2018 when making the change referenced here ;-)
It should work at best as it can – track 3 can be wave output which can't always be expressed as proper notes.

The main question is if can we close this issue, so that's why I got back to you.

@mmitch mmitch added the midi label Apr 23, 2021
@mmitch mmitch closed this as completed Aug 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants