(08-03-2022, 03:56 PM)Petr Wrote: Hi. I'll put it this way. It's all in the patterns. All of this is contained directly in the sound samples that you load via memsound. The whole science is that you have to create an empty sound signal (basically silence), which must have a sufficient frequency so that the resulting sound does not pulsate. You then modulate this empty signal with the volume of the source signal. Of course, if you use subsampling (this case) you can change the frequency. I will still work on the way to the depths, with the highest probability the intermediate sample will have to be calculated and added to the empty signal.
Just write a valid name of your audio file in the source code. Then run it and use the mouse wheel. Eq level = 100 percent means that the treble is fully equalized.
To be continued again sometime next time. I'm currently concreting the foundations of the fence (today the concrete hardens, so I hopped over to this forum), I don't have time for programming, I'm on my own. Have a nice day.
Edit: Source code updated (SIN is not need...)
Code: (Select All)'small sound equalizing example writed by Petr Preclik 03-08-2022 (dd-mm-yyyy)
$NoPrefix
Dim a As MEM, a2 As MEM, j As Long, Eq As Double
Dim As Integer Il, Ir, Il2, Ir2
s = SndOpen("b.mp3") 'insert your music file name here
a = MemSound(s, 1)
a2 = MemSound(s, 2)
f = 1
Eq = 1.7
Print "Use the mouse wheel to reduce/add the treble of the sound!"
Do Until j = a.SIZE - 2
MemGet a, a.OFFSET + j, Il
MemGet a, a.OFFSET + j + 2, Ir
MemGet a2, a2.OFFSET + j, Il2
MemGet a2, a2.OFFSET + j + 2, Ir2
j = j + 2
frL = f * (Il / -32768) + f * ((Ir / 32768) / Eq) 'create new silent empty signal. Volume in our new empty signal is drived by volume in original sound file.
frR = f * (Il2 / -32768) + f * ((Ir2 / 32768) / Eq)
SndRaw frL, frR
Do Until SndRawLen = 0
Mouse Mw
Eq = Eq + Mw
Eq = MINMAX(1, 2, Eq)
Locate 3
sLevel = Int((2 - Eq) * 100)
Print "Eq level:"; sLevel; "% "
Loop
Loop
Function MINMAX (Minimum_Value, Maximum_Value, Current_Value)
MINMAX = Current_Value
If Current_Value > Maximum_Value Then MINMAX = Maximum_Value
If Current_Value < Minimum_Value Then MINMAX = Minimum_Value
End Function
Sub Mouse (Mw)
Mw = 0
While MouseInput
Mw = MouseWheel / 10
Wend
End Sub
This is fascinating.
First, what is modulating a signal? I have seen that term over the years and just recently I read something with it, and said, "Dammit, I'm going to learn what this is, once and for all!" and promptly forgot about it by the time I was onto the next thing. Maybe if you explained like you would to a child, that'll work, LoL
At first I thought this empty signal might be the target frequency but phase-reversed, and fed back into the full sound, cancelling out that given frequency, and thus "equalizing" by means of subtraction, but I have no idea. So many questions -
* How do you give silence a frequency, if by definition it has no frequency?
* In addition to my "modulate" question, what do mean by pulsate?
* Why might this change the frequency and how do you correct for that?
* And what is subsampling?
This stuff goes way over my head, but I am interested in learning more about manipulating sound.