cienicera / cairo-wave

An implementation of the WAVE file format in Cairo
MIT License
6 stars 11 forks source link

Add get_notes_stereo #24

Open saimeunt opened 3 months ago

saimeunt commented 3 months ago

This PR provides initial support for multi-channels by adding a get_notes_stereo function to generate a stereo WAV (simply playing the default melody in the left speaker then right speaker).

I added custom channels support in the upper level directly in the MusicToWavFile converter by interleaving channels in the WAV data, not sure if we need to modify the wave generators?

@tekkac Can you please elaborate on what should I add next to get this done?

tekkac commented 3 months ago

A general might be to change the data member of the WavFile struct to handle multiple channels. maybe change it to channel_data: Span<Span<u32>>. In the case of stereo, this would be a span with two elements of data such that channel_data[0].len() == channel_data[1].len()

You will need to modify the into impl because the way to actually write the data is to interlace the channels as described in this document.