Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sound card plays the modulator channel after set to modulate multiple channels #328

Open
Fingercomp opened this issue Apr 4, 2023 · 0 comments

Comments

@Fingercomp
Copy link
Contributor

Code to reproduce the issue:

local s = require("component").sound

s.setWave(1, s.modes.square)
s.setWave(3, s.modes.sine)

s.setFrequency(1, 440)
s.setFrequency(3, 220)

s.setVolume(1, 1)
s.setVolume(3, 1)

s.setTotalVolume(1)

s.setFM(1, 3, 220)
-- ch3 now modulates ch1

s.open(1)
s.open(3)
s.delay(1000)

s.setFM(2, 3, 220)
-- ch3 now modulates both ch1 and ch2
s.resetFM(2)
-- the modulator for ch2 is now removed
-- ch3 should only be modulating ch1

s.delay(1000)
-- expected behavior: no change is observed
-- actual behavior: the sound clearly changes

s.close(1)
s.close(3)

s.process()

As far as I understand, whether a channel is mixed into the output is controlled by the isFreqMod and isAmpMod flags. They are set when the channel is set as a modulator for another channel and reset when the modulation is removed. In the code above, channel 3 is modulating two channels. The modulation of one of the carrier channels is then removed, which resets the isFreqMod flag even though the first channel still has the channel 3 set as its modulator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant