Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sound file playback (and record) - manipulating speed + pitch in realtime?
#3
Here is an equalizer program where you can change the sound frequency by pressing + or minus:  https://qb64phoenix.com/forum/showthread...558&page=2  

Speed change - try this....

Code: (Select All)

f$ = "slunce.mp3" 'must be mp3 (use single array)
Dim As Long s, t, Sze, i, Block
Dim As _MEM m

If _FileExists(f$) Then
    s = _SndOpen(f$)
    _Delay .5
Else
    Print f$; " not found."
    End
End If

If s < 1 Then Print "Error opening sound file "; f$: End
Sze = _SndRate * _SndLen(s)
m = _MemSound(s, 0)

Dim As Single Left(Sze), Right(Sze) 'load Audio do Ram
Do Until t = m.SIZE
    Left(i) = _MemGet(m, m.OFFSET + t, Single)
    Right(i) = _MemGet(m, m.OFFSET + t + 4, Single)
    t = t + 8
    i = i + 1
Loop
i = 0
speed = 1 'basic speed
Block = _SndRate \ 4 'data window - 0.25 sec

Print "Press + or - for setting music speed..."
Do Until i >= Sze - Block
    X = i
    Do Until X = Block
        If X + i >= Sze Then Exit Do
        _SndRaw Left(i + X), Right(i + X)
        X = X + speed

        Do Until _SndRawLen < .1
        Loop
        i$ = InKey$
        Select Case i$
            Case "+": speed = speed + .1
            Case "-": speed = speed - .1
        End Select
        Locate 2: Print "Speed: "; CInt(speed * 100); " percent              "
        If speed < 0 Then speed = 0

    Loop
    i = i + Block
Loop

_MemFree m
_SndClose s
Print "End."


Reply


Messages In This Thread
RE: sound file playback (and record) - manipulating speed + pitch in realtime? - by Petr - 02-04-2025, 09:14 PM



Users browsing this thread: 1 Guest(s)