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

Possibly Related Threads…
Thread Author Replies Views Last Post
  need help playing sound using certain parameters madscijr 0 389 04-01-2025, 03:52 PM
Last Post: madscijr
  List of file sound extensions eoredson 17 2,713 12-27-2024, 04:30 PM
Last Post: hsiangch_ong
  Record Arrays Kernelpanic 6 1,258 07-02-2024, 05:53 PM
Last Post: Kernelpanic
  _SndPlayFile not starting sound file eoredson 11 2,431 07-20-2023, 04:33 PM
Last Post: TerryRitchie
  incorporate sound files in code mdijkens 6 1,158 01-02-2023, 11:24 AM
Last Post: a740g

Forum Jump:


Users browsing this thread: 1 Guest(s)