Ok I'll disclose some information on my secret project (not secret anymore as of now).
I am creating an app to play Sega Genesis music (nothing new so far) and also to test instruments with LFO, SSG-EG support, 6 channel poliphony (for rich chords) also DAC and PSG (now that's kinda new/not common). For that purpose first thing I made is a standard Windows API DLL (C/C++) with the YM2612 Emulator and SN76489 emulator. Then I created some interface sound libraries, currently C# and Visual Basic 6.
Now the thing that's killing me is that all works super fine as long as I retrieve static playable sound and play it at once... but when it comes to the looping buffer I am having a very hard time geting it to play clean.
I menaged to get clean sound from my work computer writing 10 ms on each time on a 200 ms buffer, but when I tried in my less powerful laptop I got sound gaps, means my buffer system is not effective.
Here is a sample code of my simple inneficient buffer system. The code is in C#:
Code: Select all
void soundTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
lock (tlock)
{
if (sound.PlayPosition >= writePos)
{
soundEngine.UpdateMDBuffer(ref bufferByteArray);
writePos += bufferByteArray.Length;
if (writePos >= 35280) //sound.Caps.BufferBytes)
{
writePos = 0;
}
sound.Write(writePos, bufferByteArray, LockFlag.None);
}
}
}
I really tried to research on dynamic buffers but most things are based on sample playback from wave files, it gets too confuse since they're not oriented to a dynamic sound synthetizer like Shiru's TFM MM or emulators such as Gens...
Given the fact that these apps I mentioned play clean sound with immediate response (small buffer) and in all computers I tried so far... I'd like to get some tips for you guys!
And obviously of course, once I get everything working I'll release the DLL with the soundlibraries I've created. This might make easier for people to interface their apps with MD sound, such as I am doing. (or trying to)
Thank you very much.
Tulio