Open Wohlstand opened 7 years ago
Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).
What you suggest seems to be correct. channel_t
is an analog for a specific voice in the Multi_Buffer
.
This would only work for music emulators that are derived from Classic_Emu
at this point (e.g. the GB emulator, but not the SNES SPC).
Looking at the code I'm not sure that this would work until Music_Emu::mute_voices(0)
has been called manually, since the Classic_Emu
appears not to use the custom buffer that is passed in except for in mute_voices_
, and I've not seen anywhere else where that function might be called as part of initialization.
Original comment by Tom M. (Bitbucket: derselbst, GitHub: derselbst).
Ok, I'll try to work on this. In case anybody wants to follow: https://github.com/derselbst/game-music-emu/tree/multichannel
But instead implementing another custom class that does pretty much the same as Stereo_Buffer, I'll try to enhance Stereo_Buffer for holding multiple channel_t. By having some
#!c++
gme_enable_multichannel(Music_Emu* emu, int isEnabled);
Classic_Emu can decide whether to give each voice a separate channel_t or not.
Do you see any chance to get Spc_Emu
for multi channel rendering?
Original comment by Michael Pyne (Bitbucket: mpyne, GitHub: mpyne).
Spc_Emu
looks like it would need a bit of surgery within Spc_Dsp
to support multi-channel rendering (along with addressing how Echo and FIR would work broken up across independent channels). I don't think it would be horribly complicated though.
Original comment by Tom M. (Bitbucket: derselbst, GitHub: derselbst).
Ok, so instead of modifying Stereo_Buffer
, I fiddled around with Effects_Buffer
. It basically works quite well. If multichannel support is requested through gme_new_emu()
, gme will allocate an Effects_Buffer
that can hold 8 voices (maximum possible). Ofc this has to be supported by the underlying Emu type, and atm only Classic_Emu
does. Every other Emu should generate sound as before. The user can test via gme_multi_channel()
whether the output retrieved will have each voice rendered to their own stereo channel.
Please review my changes and let me know if I messed smth. up. There is one issue I could not solve, which is that strange stereo mask handling in Effects_Buffer::end_frame()
.
https://github.com/derselbst/game-music-emu/tree/multichannel
Original comment by Tom M. (Bitbucket: derselbst, GitHub: derselbst).
There seems to be a bug when trying to multichannel play vgm files (specifically Sonic 3 & Knuckles). Audio seems to be 4 times faster as usual. I'll look into that, but it may take some time until I do that. Fortunately everything sounds fine without multichannel rendering.
Original comment by Tom M. (Bitbucket: derselbst, GitHub: derselbst).
Finally had time looking into this. Sonic 3 instantiates Vgm_Emu class which internally uses requires the YM2*** FM sound chip emulators. Those have hardcoded stereo support. There are just so many sample buffers and resample buffers floating around that I completely lost overview. Unfortunately the only option I saw was to disable multichannel support for Vgm_Emu class, see the commit I pushed to my github fork.
Original report by Tom M. (Bitbucket: derselbst, GitHub: derselbst).
I would like to be able to render each voice to a distinct stereo buffer. Currently this doesnt seems to be easily possible?
As far as I understand, one would have to implement a custom Multi_Buffer class holding an array of channel_t[Music_Emu::voice_count()] and then set this custom buffer via Music_Emu::set_buffer(). Am I missing something?