Closed jaybaird closed 1 year ago
I didn't see an obvious way to update the documentation. If you accept this, let me know how I can help document!
Thanks. Is the only change to the computation this part? https://github.com/mackron/miniaudio/pull/675/files#diff-f31380d18dd03a06089b755f2b5ccd5e568ac32f0b30b240492b75f32cee4e5bL65234-R65260
I'm a bit divided on this. On one hand, it seems like such a trivial change to introduce a whole new type, but on the other hand it does kind of make sense to have a separate pulse wave object since it is a different type waveform. I'll sit on this and have a think about it.
While I consider this, a quick change to your PR - are you able to swap your parameters here: https://github.com/mackron/miniaudio/pull/675/files#diff-f31380d18dd03a06089b755f2b5ccd5e568ac32f0b30b240492b75f32cee4e5bR10121-R10122. The reason for this, is that by having ma_waveform
be the first member, it becomes compatible with ma_data_source
.
Thanks. Is the only change the computation this part? https://github.com/mackron/miniaudio/pull/675/files#diff-f31380d18dd03a06089b755f2b5ccd5e568ac32f0b30b240492b75f32cee4e5bL65234-R65260
That's correct.
I'm happy to merge this. The additional code is only trivial so I don't think it'll add too much maintenance costs.
A very quick and unimportant side note. This PR is missing the declaration of set_duty_cycle()
. I'll add it manually post merge.
Adds a
ma_pulsewave
generator type to allow a pulse wave with a custom duty cycle. It does not change or break any existingma_waveform_type_square
implementations and is/should be 100% backward-compatible. Under the hood,ma_pulsewave
is a thin wrapper around ama_waveform
of typema_waveform_type_square.
ThedutyCycle
is defaulted to0.5
forma_waveform
square waves, and forma_pulsewave
is plumbed through accordingly.Let me know if you'd like to not wrap things like this. It seemed prudent to use as much code as was there as it's been tested and reviewed. I did this to add the API I was looking for but wanted to retain backward compatibility. e.g., a squarewave is a pulse wave, but this inversion allows for the least surface area change.