frno7 / psgplay

PSG play is a music player and emulator for the Atari ST Programmable Sound Generator (PSG) YM2149.
24 stars 4 forks source link

Is it a wanted side effect to not be able to read digital data if a stereo frequency is set? #20

Closed tin-nl closed 2 years ago

tin-nl commented 2 years ago

While writing out the 3 single channels I stumbled upon: https://github.com/frno7/psgplay/blob/7a5b345cf4e96d96ffe60cd6dddd4ee83c282293/lib/psgplay/psgplay.c#L422 Shouldn't this be !pp->stereo_frequency ?

frno7 commented 2 years ago

No, it’s documented that way:

https://github.com/frno7/psgplay/blob/7a5b345cf4e96d96ffe60cd6dddd4ee83c282293/include/psgplay/psgplay.h#L29-L32

The reason is that psgplay_read_stereo and psgplay_read_digital are mutually exclusive: they cannot be used simultaneously with the same pp object, because psgplay_read_stereo is buffering samples (due to downsampling and so on). Trying to use both would be undefined and erratic, so requiring a zero frequency for digital reading is a safeguard so that the application knows what it’s doing.

tin-nl commented 2 years ago

Thanks for the explanation - I simply did not see the header documentation, sorry for the noise :) Will initialize in my dump tool accordingly.

frno7 commented 2 years ago

Another alternative could be to require the frequency to be exactly 250 kHz for digital reading, but, that could potentially be useful with stereo reading too (which a zero frequency definitely isn’t). :-)