-
Notifications
You must be signed in to change notification settings - Fork 71
volume #57
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
volume #57
Conversation
from adafruit_circuitplayground.express import cpx
newvol = -(2**12)
cpx.play_tone(220, 2, newvol) tone example with volume |
Would be useful to document the volume variable including the appropriate range of values and the default in the docstring? What happens if you go too loud, does it throw an exception? Are there any precedents for volume variables in the codebase? Are there any solid plans for doing this elsewhere, e.g. there might already be some future ideas on extending the new audioio.Mixer ? BTW, there's mention of 0.0 to 1.0 in adafruit/circuitpython#1306 |
yes something can be done like that around lines 566 to 569, but im not sure how to do that.... think i could use something like this for louder but not sure about less quite int(255* max( 0, min( 1, (1-value) )) ) looks like most that other stuff is for .wav files |
How does this handle going "too loud", i.e. exceeding the permited range on values? I note CircuitPython 4.x has changed behaviour on values that are out of range for
|
An example of errors from exceeding the 16 bit limits:
I'd imagine bad things are likely to happen to values to, even the DSP-esque saturate approach isn't nice here. |
shift = 2 ** 15 | ||
for i in range(length): | ||
yield int(tone_volume * math.sin(2*math.pi*(i / length)) + shift) | ||
|
||
def _generate_sample(self, length=100): | ||
def _generate_sample(self, length=100, volume=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written, won't this cause the first volume used to apply to all samples until a restart?
@hexthat There is new discussion on this PR. As well, the library has been entirely restructured since you submitted this, and therefore inclusion of your change will require a significant change to this PR. If this is something you're still interested in seeing included, it may make more sense to submit a new PR to the newly structured library, unless you're comfortable with advanced |
I'm going to close this PR. If you still wish to add this feature, please consider submitting a new PR in this case, as the library was entirely restructured since it was submitted. These changes would now be added to |
No description provided.