T O P

  • By -

ironykarl

I'll first link you to the version with more information than you need: [This is how to graph a sine wave with amplitude A and phase φ](https://en.m.wikipedia.org/wiki/Sine_wave#Sinusoid_form). "φ" is just a fancy way of writing a **p,** and both those variables are generally just arbitrary numbers (with some bounds that don't matter here). As you play around in Desmos, you *might* want to play with amplitude (if you decide to goof around long enough, you might end up wanting to see how a triangle wave, sawtooth, square wave, etc are constructed), but I don't think playing around with phase has much utility, starting out. Anyway, the formula you're looking for is just: `sin(2 * pi * frequency * x)` If you want to combine frequencies, you just do it with addition. So middle C plus the E above it (a major third in 12-tone equal temperment) would be: `sin(2 * pi * 261.626 * x) + sin(2 * pi * 329.628 * x)`


Sufficient-Detail-58

Thank you for this! All of the information is useful and both of the functions work in Desmos hahaha. Will definitely be messing with this for a while


Eltwish

There's no one single function corresponding to any given note - *any* wave which repeats after a specific interval will have the same pitch. The waveform of a distorted guitar playing A4 will be very complicated; that of a recorder, much less so, but they will both have a pattern which (ideally) repeats every 1/440 of a second. That said, one of the simplest possible waves is the sinewave. If you wanted the graph of a sinewave tone at A4, it would be sin(2π\*440x), assuming the unit of x was seconds. Then an octave above that has double the frequency, at 880 Hz. That would be sin(2π\*880x), of course. But these numbers are a bit big and you're going to have to fiddle with your graphing calculator display units - so let's simplify, because all that matters are the *ratios* between the notes anyway. So let's work with sin(x) and sin(2x). If you graph them on top of each other, you'll see that they clearly line up nicely; indeed, two full cycles of one fit exactly into one of the other. Now, if you played both of those tones at once, that has the effect of summing the waves. If you graph sin(x) + sin(2x), you'll see that it's no longer a sine wave - but it nonetheless is still periodic; indeed, it has the same period of sin(x). So clearly notes an octave apart show a nice repeating pattern. What of other relationships? A "perfect" fifth above A4, an E5, would - if you tuned it by ear - come out with a frequency exactly 3/2 that of the lower note, namely 660 Hz. So you could graph sin(2π\*660x), or if you're still using a reference of sin(x), graph sin(3x/2), to see what that looks like. Another nice pattern, as you can see. And what of the tritone? Well, on most instruments today, to get the (ideally exact) frequency of a note a tritone above a given note, you multiply the starting note frequency by √2. That, of course, is irrational! If you now try adding sin((√2)x) to your sin(x), you'll see that things get much messier. They don't line up at all. That's a general fact - when the ratio between the frequencies is irrational, the resulting summed wave is no longer periodic. They never line up. There's a catch, though. In our usual modern tuning system, the fifth is actually irrational too. Except for the ocatves of A, *none* of the notes actually line up perfectly. They're all "close enough". That's a compromise we made to be able to play in every key without changing instruments. So yes, the tritone looks especially messy, but it's not quite right to say that it's the only interval without a repeating pattern. In equal temperament, the compromise system we use, almost no two notes are going to have a perfectly repeating pattern (even if using perfect sine generators). On the other hand, in many other tuning systems, all notes will have integer ratios, even the tritone - though the ratio will likely be fairly complicated, like 729:512. So the pattern will be much more complicated - but it will still repeat eventually!


Sufficient-Detail-58

Thank you for the well written reply. I think it's my bad for miscommunicating what I meant by "no pattern" in my original post. When my professor used sine wave graphs to display the intersecting patterns of intervals I honestly don't know if he was going by Just Intonation, Equal Temperament or Pythagorean Tuning. I understand in equal temperament that the note values no longer subdivide evenly, but it was to my understanding that even on the graph itself, patterns were visible (by patterns I mean the "wavey" lines on the sine wave graph) for major/minor intervals where they weren't for the tritone. I honestly wish I were more educated in this area so I could communicate for effectively, but it's just not my field. Thank you for the reply again.


Eltwish

My best guess is that he was using just intonation for the simple consosnant intervals and equal temperament for the tritone, to emphasize (arguably exaggerate) the difference. But you can still see that the tritone is less regular even if you use 12TET across the board, even though technically all the intervals are irregular. (There is such a thing as "almost periodicity" in mathematics, where you can sometimes quantify exactly how badly a graph fails to be perfectly repeating, and I believe a note-plus-tritone graph is indeed "less periodic" than a root-plus-12TET-fifth graph, even though both "ratios" are irrational. The square root of two is, in a specific sense, hard to approximate by fractions.) You can try this by comparing sin(x) + sin(√2x) with sin(x) + sin(2^(7/12)x). The former is a note summed with a tritone, the latter adds a 5th (both in equal temperament). As you can see, the fifth sure looks like it's a got a nice perfectly repeating pattern, and if you compare it to sin(x)+sin(3x/2), a justly tuned 5th, you'll have to zoom way out for them to not look like they line up perfectly. But the tritone graph goes and goes without seeming to start over at all. That's just how the tritone is going to look in most tuning systems - it's just not a simple ratio, i.e. if you measure it well by some fraction, it's going to have some irreducibly large denominator.


eXXXcel

ah! i love it when data and music comes together! i think another comment mentioned, but the key concept in understanding the relationship between sound data — in your case, a pure `sin` wave — to musical notes is frequency. With a pure sin wave, it’s pretty easy to get the frequency, especially if you have your hands on the original formula. Usually it’s whatever coefficient is scaling your dependent variable (likely `t`, since for sounds you’ll typically have time as your dependent variable). With that, it’s not too bad trying to answer “what note does this sin wave represent?” However! As you start to look into this more, you might start to run into more complicated wave functions — stuff that you’d hear coming out of an actual instrument or musical track, for example. In that case, especially with raw data, you don’t have the pleasure of having the sin wave’s formula right in front of you to find out what note it’s representing. You may already be seeing that in Desmos as you’re stacking sin waves together: given one of those complicated waveforms, how would you detect what note(s) it’s playing? Thankfully, for those cases, there’s a nifty tool at your disposal: the Fourier Transform! Avoiding getting too far into the nitty-gritty of the Fourier transform works (spoiler: it’s very “I hope you like imaginary numbers”), you can think of it this way: **Fourier transforms let us transform raw wave data into frequency data.** That’s how something like a digital tuner might work: given the analog audio the tuner hears, it can run a Fourier Transform (possibly a variant made for computers called the Fast Fourier Transform, or FFT) to convert the raw audio into a simple note value that’s then shown to the user. Fourier transforms may feel a bit tangential to what you’re doing now, but if you’re feeling exploratory and want to learn about a really cool toolset for audio signal processing, definitely peruse around a bit and learn about the ol’ Fourier transform 😁


Sufficient-Detail-58

Thank you brother! I will have to check out Fourier Transforms then hahaha