We’re rewarding the question askers & reputations are being recalculated! Read more.

New answers tagged

0

Some findings: Your for loop iterates over 71 results, but your array has only the length 70. You may overwrite variables in the memory behind the array. You can use else instead of else if (i >= 70 * 0.1) because it is just the negation of the if (i < 70 * 0.1). In the else case (i >= 70 * 0.1) is always true. What is the type of myVariable? ...


2

You just have to add the waveforms. For example, if you want to play pure tones (the simplest and most boring timbre), you generate a sine wave for each of them and add them together: struct Note { float frequency; float phase; bool is_active; } notes[MAX_NOTES]; void output_sample() { static uint32_t previous_time; uint32_t now = ...


0

Sound is nothing else than a multiple simple waves combined in to one. So, theoretically you can play as many sounds (tones) as you like on a single pin. If you want to go true analog than you probably want to use a sin wave to generate sound. However, in that case you can do the following: Either make a function that would be capable of generating a sin ...


Top 50 recent answers are included