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

refactor soundwave livebook #271

Merged
merged 2 commits into from
Feb 13, 2024
Merged

refactor soundwave livebook #271

merged 2 commits into from
Feb 13, 2024

Conversation

mat-hek
Copy link
Member

@mat-hek mat-hek commented Feb 12, 2024

No description provided.

@mat-hek mat-hek requested a review from varsill February 12, 2024 17:12
Comment on lines 147 to 148
Kino.render(chart)
chart
Copy link
Contributor

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

Suggested change
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
Copy link
Contributor

@varsill varsill Feb 13, 2024

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:

Suggested change
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)

Copy link
Member Author

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] 🤔

@mat-hek mat-hek requested review from varsill and removed request for varsill February 13, 2024 11:46
@mat-hek mat-hek merged commit c287b7c into master Feb 13, 2024
1 check passed
@mat-hek mat-hek deleted the refactor-audio-plot branch February 13, 2024 13:28
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

Successfully merging this pull request may close these issues.

2 participants