Wavetable Synthesis in Rust?? Rust Basics Tutorial [Synth #004]

preview_player
Показать описание
✅ Please subscribe to WolfSound to let the little Wolf 🐺 grow:

Hi, my name is Jan Wilczek and I am an audio programmer and a researcher. Welcome to WolfSound!

WolfSound enables everybody to learn about audio programming!

In this video, we are implementing a wavetable synthesizer in the Rust programming language. You will learn:
✅ how to output sound with Rust,
✅ how to implement a sine oscillator in Rust with wavetable synthesis,
✅ how a Rust project is structured,
✅ how to manage dependencies in Rust, and
✅ how to compile and run a Rust project.

In case of any doubt in understanding, please, refer to the article above or ask a question in the comments 🙂

ABOUT ME

FOLLOW WOLFSOUND ONLINE

TIME CODES

00:00 Introduction
00:45 What is Rust?
01:18 What will you learn in this video?
01:54 Prerequisites
02:15 Rust project setup (introduction to Cargo)
02:42 Building and running a Rust application
03:36 Generating the wave table (Rust's Vec type and the for-loop)
07:30 WavetableOscillator class (creating a Rust class)
08:44 Constructing functions in Rust
09:48 set_frequency(), get_sample(), and lerp() functions (ownership in Rust)
12:28 Sound playback using the rodio library (Rust traits)
16:17 Sine playback demonstration
16:41 Summary

#rust #audio #synthesis #sound
Рекомендации по теме
Комментарии
Автор

I find myself really lucky to finally find a great resource including both Rust and Audio programming!! Please continue making videos, this was a really insightful video

albertoromero
Автор

"Its syntax is similar to C++ so it's easy to learn"
There is so much wrong about this sentence, don't even get me started :'D

Love your videos btw.! Very nice that you're using rust here, it would be awesome if you'd do more rust related stuff in the future :)

flyingsquirrel
Автор

I would love to see more Rust videos from you! Very glad you are making this channel. It's something I have wished existed for a while! Cheers

saysthetedd
Автор

Great video and corresponding article! I'm trying to like programming as a hobby again, so Rust and audio are my main source of interest

from_right_to_left
Автор

ohhh i need more of this. rust audio development is awesome.

samdroid
Автор

I really enjoyed the video. Your explanations of what each thing you are doing is very clear and would be very useful to rust beginners. Rather than just throwing rust concepts at the viewer, you make sure to walk them through your process of why you did what you did and also explain what language features you used to achieve it.

dusterthefirst
Автор

Great video!

One correction needed though: this is not a "wavetable" (at least as defined by Wolfgang Palm, who invented this type of synthesis) - it is just one single cycle waveform. A "wavetable" would be 64 (for example) such single cycle waveforms. An example might be a gradual morphing of the sine wave you have here into a sawtooth wave. Position in the wavetable can be controlled via an envelope or some other modulation to create complex and interesting sounds.

craig_z
Автор

Hello: Really nice videos you have out there about the topic of wave table synthesis. I have learned quite a bit. On the rust side of things here is a tip you might like. If you want squeeze a little bit more of performance you could do the following: Use the stack instead of the heap memory. Instead of using a Vec you could use an Array leveraging on the fact that you are using a fixed table. Stack variables have way more faster access than heap ones. You could reformulate your struct like this without sacrificilt the posibility of the ability to parametrize the size of the wave table:

struct WaveTableOscillator<const N: usize>{
sample_rate: u32,
wave_table: [f32; N],
index: f32,
index_increment: f32,
}

And then when you initialize you structure you could define at compile time any arbitrary size of the table including value initialization with no cost at runtime:

let a = WaveTableOscillator{
sample_rate: Default::default(),
wave_table: [0.0f32; 64],
index: Default::default(),
index_increment: Default::default(),
};

Another trick could be to switch the data types of the index from f32 to i32 which are way more faster to compute and using from Rust's standard library the "simd" module to run the functions parallel calculations for floats to boost even more.

Nice job you did here!

andres-hurtado-lopez
Автор

Very good intro! thanks for walking through all this and exposing Rust concepts too :)

jonatasdp
Автор

This is awesome, many layers of precisely what I was seeking to learn.

aaronocelot
Автор

this video taught me so much about Rust and Audio at the same time. Thanks.

persistent-programmer
Автор

Small nitpick, you don't actually need to call convert_samples() on your oscillator (line 57), since it already returns f32 values

CHEyp
Автор

You made it seem so natural and simple to make a synth. Great content!

Havoid
Автор

wow! I'm learning rust and I also like audio synthesis in software. Awesome!

juanma
Автор

Man I never been happier to try and build my first synth from scratch
thank you hell a lot, this been my introduction to audio programming 🥰🥰🥰🥰

Talel_kraiem
Автор

Hey man would absolutely love if you made more videos expanding on this tutorial. I'm a rust engineer and also love making music and me and my friends wanna make VST plug-ins for ourselves.

This was super useful but would love to get more explanation and learn how to develop more complex stuff because this is all unchatered territory for me.

Looking forward to seeing the next video king

thelenardjourney
Автор

Where was convert_samples() defined for WavetableOscillator?

nicholascarr
Автор

I would to see a whole playlist on studio programming with rust.

bakdiabderrahmane
Автор

Please make more videos about Rust!! Such a great language

guidofazzito
Автор

I was wondering if it’s possible to make this compile to WASM since I wanted to make a web based platform independent DAW

JoeyLindsay