Beats in signals of three or more sinusoids. Possible discovery.
Started by 6 months ago●7 replies●latest reply 6 months ago●269 views#Python
Hello,
I have been on a journey trying to discover a way to outline ‘beats’ in signals comprised of three or more sinewaves. This project started since I couldn’t and still can’t find anyone else who has come across a solution. On Stack Exchange they are telling people to use Wolfram Alpha, instead of having a standardized formula/ equation. I don't find this sustainable.
I have written a python program that can be handed a list of intervals. If we have the frequencies 1,2,4,7 and 11, the list of intervals should be 1,2,3,4. There is a "basefreqency" parameter that decides the place the intervals will start from.
Here's the equation for 3 sinusoids since I wrote the program for four or more...
sin(t*f_1) + sin(t*f_2) + sin(t*f_3)
has this beat.
2*(cos(t*((f_2-f_1)+(f_3-f_2))/2)+cos(t*((f_2-f_1)-(f_3-f_2))/2)/2)
Note: The Program Outputs a Figure of Both the Sinewave Signal and the Beat outline. A mathematical model is also outputted from your given amount of intervals... By itself the program generates the intervals by random, This is easy to change for your own experiments.
https://www.dsprelated.com/showthread/comp.dsp/88415-1.php
https://physics.stackexchange.com/questions/400960...
- Johannes Dvorak
import numpy as np import matplotlib.pyplot as plt ################################################################################################### baseFreqency = 100 #Interval generator f = np.random.random(10) #Amount of intervals. Minimum 3 iAmount = len(f) x = np.linspace(0,np.pi*8,50000) ################################################################################################### #Freqency listing Freqency = baseFreqency for i in range(len(f)): Freqency += f[i] print(f"Freqency {i}: ", Freqency) print() #Signal of beat filler = "" sin = "np.sin(x*baseFreqency)" for i in range(iAmount): var = f"f[{i}]" filler += f"+{var}" sin += f"+np.sin(x*(baseFreqency{filler}))" print(sin) print() #Beat freqencies Vs = ["((f[0]+f[1]+f[2])/2)","((f[0]-(f[1]+f[2]))/2)","((f[2]-(f[1]+f[0]))/2)","((f[0]+f[1]+f[2]+f[3]*2)/2)"] Vex = "((f[0]+f[1]+f[2]+f[3]*2" Vpost = ")/2)" for i in range(iAmount-4): fInsert = f"+f[{i+4}]*2" Vex += fInsert Vs.append(Vex+Vpost) #Beat outline for i in range(iAmount-1): if i == 0: cos = f"(np.cos(x*{Vs[i]})" cos += f"+np.cos(x*{Vs[i+1]})*0.5 " cos += ")*2" print(cos) #Waves ySin = eval(sin)/iAmount yCos = eval(cos)/iAmount yCombine = (yCos+ySin)/2 plt.plot(x,ySin,c="k") #plt.plot(x,yCombine,c="brown") plt.plot(x,yCos,c="tomato") plt.show()
EDIT:
The program is obselete.
Here is a mathematical formula for beats in any signal:
$$ \text{n is the amount of sinewaves. } f \text{ is a frequency.} A \text{ is amplitude. } \phi \text{ is phase.}$$
$$ \sum_{i=1}^{n}{\sin{(x \cdot f_i+ \phi_i) \cdot A_i}} $$
$$ \text{has this beat.} $$
$$ \sum_{i=1}^{n}{\cos{(\frac{x \cdot (-f_1-f_n+2 \cdot f_i)}{2}+\phi_i) \cdot A_i}}$$
If you wish to tinker around with the equations in a playground environment. I have set up this desmos calculator here.
Did you know this site can use MathJax? Rewriting your comment gets:
Here's the equation for 3 sinusoidal waveforms since I wrote the program for four or more...
$$\sin(t*f_1) + sin(t*f_2) + sin(t*f_3)$$
it has this beat.
$$2*(cos(t*((f_2-f_1)+(f_3-f_2))/2)+cos(t*((f_2-f_1)-(f_3-f_2))/2)/2)$$
Which is slightly easier to read for me. But I'm curious how you are defining the term "beat". Are you attempting to find the shortest interval over which the combination repeats?
If there are more than 2 sinusoids at the same time, the amplitude patterns within one period can change dramatically if you change the phase relationships or the frequency ratios of the sinusoids.
For example, if you mix frequencies of 3 Hz, 7, 11, 15, and so on, all the way up to 19999 or so, it will sound as if the signal were periodic in 4 Hz but it is actually periodic in 1 Hz.
If the frequencies were irrational and all their consecutive differences were 4, again it would sound as if the signal were periodic in 4 Hz but in fact then the signal would not be periodic at all.
So I'm not sure what exactly you're trying to find.
If you want to delve deeper into this topic, I would encourage you to do some experiments with amplitude modulation and phase shifting. In fact, any high-frequency sinusoid can always be found as a product of several low-frequency sinusoids.
I am trying to find waves that envelope signals build from sinewaves with equal amplitude and zero phase, kind of like beats.
In the research I have done to come up with my equations I have stumbled upon two types of beats. Perfect and imperfect beats.
The equation that is widely known to find beat frequencies for signals made from two sinusoids is what I call a perfect beat. This is because the beat outline tangents every local maximum and minimum. Perfect beats also show up under the right conditions in my equations. In the equation for beats of signals with three sinewaves, there are conditions needed to be met to get a perfect beat. The conditions are as follows.
$$ f_1 < f_2 < f_3 $$
And
$$ f_2-f_1 = f_3 -f_2 $$
Perfect beats don’t just show up in signals with 2 or 3 sinewaves. It can also be observed in a signal with 4, under the right conditions. Here is a Desmos calculator that shows this. This also demonstrates a sort of beatseption, a beat inside a beat.
https://www.desmos.com/calculator/jverrz2ys9
Imperfect beats are the most common sorts of beats. These show up all the time in my equations which is a possible mistake on my part, but even if it is a mistake, it doesn’t make the waves any less interesting. Imperfect beats secant every period of the signal and they never exceed local minimums or maximums. If you look at an imperfect beat it is clear that they surf inside the signal
(I don’t know how else to explain this).
Note: To observe beats as clearly as possible it is recommended that the base frequency should be high. This is because the beat outline is calculated with the intervals between notes and not the individual frequencies.
Hope this explains some things:)
If it's enough for you if I try to look into it during the weekend, I might have something to add here later. I don't know the exact formulas and relationships from the top of my head but I suspect I might at least find a partially relevant answer, even if not to all that you're asking about.
P.S.:
I should probably warn you about some differences in mathematicians' terminology vs. musicians' terminology. Not sure which context or which field of science you're trying to use your results in; but when talking about musical acoustics, the term "interval" usually means an interval size expressed in some logarithmic units, like cents or semitones or octaves (i.e. the logarithm of the frequency ratio), or occasionally the frequency ratio itself. That is, what you're talking about would then simply be called "frequency difference", not "interval size", even if you mean relative frequencies rather than absolute frequencies.
Possibly related to CFR (Crest factor reduction) also named as peak limiting. Used extensively in ofdm systems to reduce peak to average ratio(PAR). Such modules detect peaks above a threshold and within a given window.
Here is a mathematical formula for beats in signals with more than three sinewaves:
$$ \text{n is the amount of sinewaves. } f \text{ is a frequency.} $$
$$ \sum_{i=1}^{n}{\sin{(x \cdot f_i)}} $$
$$ \text{has this beat.} $$
$$ \sum_{i=1}^{n}{\cos{\frac{x \cdot (-f_1-f_4+2 \cdot f_i)}{2}}}$$
If you wish to tinker around with the equations in a playground environment. I have set up this desmos calculator https://www.desmos.com/calculator/nlmd0amkff .