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

feat: implemented sine wave #18

Closed
wants to merge 5 commits into from

Conversation

Oshioke-Salaki
Copy link

@Oshioke-Salaki Oshioke-Salaki commented Mar 22, 2024

fixes #9

Copy link
Collaborator

@tekkac tekkac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now the test file is filled with 0.
Please make sure the out put Wav is actually the one we want.
Check the review comments for insights.

src/utils.cairo Outdated
break;
}
let t: u32 = ((num_samples_left - 1) / sample_rate_hz.into()).try_into().unwrap();
let fp: FP16x16 = FixedTrait::new_unscaled((2 * (22 / 7) * frequency_hz * t), false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funny Pi Approximation, maybe orion has Pi as a const though.

src/utils.cairo Outdated
}
let t: u32 = ((num_samples_left - 1) / sample_rate_hz.into()).try_into().unwrap();
let fp: FP16x16 = FixedTrait::new_unscaled((2 * (22 / 7) * frequency_hz * t), false);
let sample_value: u8 = fp.sin().try_into().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you need to scale the sinewave to fit the 8-bit bit depth as this returns 0_u8 for now.

https://en.wikipedia.org/wiki/Audio_bit_depth

(Probably something like 128*sin + 128)

@tekkac tekkac closed this Apr 17, 2024
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.

Implement sine wave generator
2 participants