-
Notifications
You must be signed in to change notification settings - Fork 30
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
refactor soundwave livebook #271
Conversation
livebooks/soundwave/soundwave.livemd
Outdated
Kino.render(chart) | ||
chart |
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.
[NIT] It should be fine as Kino.render/1
returns the chart
Kino.render(chart) | |
chart | |
Kino.render(chart) |
for <<sample::binary-size(state.bytes_per_sample) <- buffer.payload>> do | ||
RawAudio.sample_to_value(sample, ctx.pads.input.stream_format) | ||
for <<sample::binary-size(sample_size) <- buffer.payload>> do | ||
RawAudio.sample_to_value(sample, stream_format) / sample_max |
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.
Shouldn't it be more like:
RawAudio.sample_to_value(sample, stream_format) / sample_max | |
RawAudio.sample_to_value(sample, stream_format) / (sample_max-sample_min) |
?
(I am a little bit worried it won't get rescaled properly in case we have a signed number as a sample value)
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.
I think PortAudio returns signed numbers by default. sample_max
is around 2^15
and sample_min
is around -(2^15)
, so by dividing by sample_max
we're getting [-1, 1]
. After the proposed change, I think we'd get [-0.5, 0.5]
🤔
No description provided.