Closed dcoredump closed 2 years ago
Do you want to output the audio from off this?
I thought I could use the OPN2_Clock() function, but this seems to calculate only a single sample, doesn't it?
Correct, by default it outputs only one sample and you should query it as many times as your final buffer is. You may find the slightly-extended version of this emulator:
https://github.com/Wohlstand/libOPNMIDI/blob/master/src/chips/nuked/ym3438.h
https://github.com/Wohlstand/libOPNMIDI/blob/master/src/chips/nuked/ym3438.c
where are friendly overlays has been added to generate the output. Keep the note, you will need to use the OPN2_GenerateStream() or OPN2_GenerateStreamMix() calls to get the 44100 output, however, it's better you will use a different resampler (for example, ZitaResampler or libsamplerate) as built-in resample is a simple linear one. Or, you may just take the internal processing code and use it with the mainstream emulator directly. Also note, you should use OPN2_WriteBuffered()
to pass the data into the chip that will be proceeded by OPN2_GenerateStream() or OPN2_GenerateStreamMix(). The default emulator using logic is the similar to the dealing with the real chip.
Hi @Wohlstand,
many thanks for your fast answer! This is was I was looking for - great! Currently my only question is how to use the clock parameter for OPN2_Reset(chip_r, rate, clock)
? For rate I am using 44100 but what is the value for clock?
TIA, Holger
For rate I am using 44100 but what is the value for clock?
You can use one of two known Sega clock values used for PAL and for NTSC
You can use any sample rate you want, but the clock is usually the constant, I do use 7670454
at libOPNMIDI.
See Issue #19
Hi @nukeykt and many thanks for this cool project!
I tried to use your code to make a Teensy C++ audio object out of it. But for this I would have to fill a 128 byte buffer in the update() method (at 44100 Hz). I can't quite figure out how to do this. Can you give me a hint?
I thought I could use the OPN2_Clock() function, but this seems to calculate only a single sample, doesn't it?
I would be very happy if you could give me a short hint.
Greetings, Holger