Functional sound equalization live!
#6
Hi. My comment is misleading. That statement about sufficient signal frequency comes from another source code. I simply tried to create a 100 Hz carrier signal and then modulate it with sound. This is shown by the attached source. Try changing the SignalSpeed variable.

For clarification. SNDRATE is the audio sampling rate. That's 44100 samples per second. By definition of audio, the sampling rate of the audio must be twice as high as the maximum recorded frequency. For 44100 samples, the maximum possible frequency is 22050 Hz.
So if you needed to record sound with a frequency of, say, 88.2 Khz, you would do it like this: For 88.2 KHz, you need exactly as many samples as for 4 seconds of sound at a sampling rate of 44100 samples per second. So just record the sound within 4 seconds and then speed it up 4x for playback.

Subsampling - if you have audio whose sample rate contains 44100 samples per second, you can play it with a quarter of its samples at the cost of losing quality. In practice, you do this by playing every fourth sample four times. That's to meet 44100 samples per second. If you were to play each sample only once, the result would be a 4x accelerated sound.

This leads to another possibility - smooth regulation of sound speed, it can be regulated by the number of dropped samples and the number of their playback.


Frequency modulated as sound:
Code: (Select All)
'create signal (100 hz) and then modulate this frequency as sound:
$NoPrefix
SignalSpeed = 0.01 '100 Hz = 100 changes per 1 second. Periode time is 1 / 100
Audio = SndOpen("be happy.mp3")
Dim As MEM L, R
Dim As Integer LeftSignal, RightSignal
Dim As Long C
L = MemSound(Audio, 1)
R = MemSound(Audio, 2)

Do Until C = L.SIZE - 2
    MemGet L, L.OFFSET + C, LeftSignal
    MemGet R, R.OFFSET + C, RightSignal
    s = s + SignalSpeed
    SndRaw Sin(s) * (LeftSignal / 32768), Sin(s) * (RightSignal / 32768)
    C = C + 2
    Do While SndRawLen > 0
    Loop
Loop

Play audio in subsampled form:
Code: (Select All)
'play sound using 11025 samples, not 44100
$NoPrefix
Audio = SndOpen("be happy.mp3")
Dim As MEM L, R
Dim As Integer LeftSignal, RightSignal
Dim As Long C
L = MemSound(Audio, 1)
R = MemSound(Audio, 2)

Do Until C = L.SIZE - 8
    MemGet L, L.OFFSET + C, LeftSignal
    MemGet R, R.OFFSET + C, RightSignal
    For U = 1 To 4
        SndRaw LeftSignal / 32768, RightSignal / 32768
    Next
    C = C + 8 'as STEP 4, its INTEGER (2 byte), so 8
    Do While SndRawLen > 0
    Loop
Loop

and small upgrade previous code - play sound fast:

Code: (Select All)
'play sound using every 4'th sample
$NoPrefix
Audio = SndOpen("be happy.mp3")
Dim As MEM L, R
Dim As Integer LeftSignal, RightSignal
Dim As Long C
L = MemSound(Audio, 1)
R = MemSound(Audio, 2)

Do Until C = L.SIZE - 8
    MemGet L, L.OFFSET + C, LeftSignal
    MemGet R, R.OFFSET + C, RightSignal
    'For U = 1 To 4
    SndRaw LeftSignal / 32768, RightSignal / 32768
    'Next
    C = C + 8 'as STEP 4, its INTEGER (2 byte), so 8
    Do While SndRawLen > 0
    Loop
Loop

Big Grin


Reply


Messages In This Thread
Functional sound equalization live! - by Petr - 08-03-2022, 03:56 PM
RE: Functional sound equalization live! - by Jack - 08-03-2022, 04:12 PM
RE: Functional sound equalization live! - by Petr - 08-03-2022, 04:19 PM
RE: Functional sound equalization live! - by Petr - 08-03-2022, 04:23 PM
RE: Functional sound equalization live! - by Petr - 08-06-2022, 01:23 PM
RE: Functional sound equalization live! - by Pete - 08-06-2022, 03:27 PM
RE: Functional sound equalization live! - by Pete - 08-06-2022, 05:37 PM
RE: Functional sound equalization live! - by Petr - 02-18-2023, 03:38 PM
RE: Functional sound equalization live! - by Petr - 02-18-2023, 08:05 PM
RE: Functional sound equalization live! - by Petr - 02-18-2023, 09:52 PM
RE: Functional sound equalization live! - by Petr - 02-19-2023, 12:40 PM
RE: Functional sound equalization live! - by Petr - 02-19-2023, 03:39 PM
RE: Functional sound equalization live! - by Petr - 02-22-2023, 07:25 PM
RE: Functional sound equalization live! - by Petr - 03-03-2023, 11:53 PM
RE: Functional sound equalization live! - by Petr - 03-04-2023, 04:21 PM
RE: Functional sound equalization live! - by Petr - 03-24-2023, 08:35 PM



Users browsing this thread: 4 Guest(s)