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

volume #57

Open
wants to merge 6 commits into
base: master
from

Conversation

@hexthat
Copy link
Contributor

hexthat commented May 9, 2019

No description provided.

hexthat added 2 commits Jan 1, 2019
@hexthat

This comment has been minimized.

Copy link
Contributor Author

hexthat commented May 9, 2019

from adafruit_circuitplayground.express import cpx

newvol = -(2**12)

cpx.play_tone(220, 2, newvol)

tone example with volume

@hexthat hexthat marked this pull request as ready for review May 9, 2019
hexthat added 3 commits May 9, 2019
@hexthat hexthat changed the title volume and melody volume May 11, 2019
@sommersoft sommersoft requested a review from adafruit/circuitpythonlibrarians May 13, 2019
@kevinjwalters

This comment has been minimized.

Copy link

kevinjwalters commented May 13, 2019

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

@hexthat

This comment has been minimized.

Copy link
Contributor Author

hexthat commented May 15, 2019

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

@kevinjwalters

This comment has been minimized.

Copy link

kevinjwalters commented May 29, 2019

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 array.array:

bytearray, array.array, and int.to_bytes() now check for values that are too large to fit. This matches CPython behavior. Thanks to godlygeek.

@kevinjwalters

This comment has been minimized.

Copy link

kevinjwalters commented Jun 22, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.