Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mp3 Speed
#1
Change the speed (tempo) of an mp3 file. Files needed in the zip file (mp3 speed.zip)

Code: (Select All)

'------------------------------------------------------------------------------------------------------------------------
' Files needed        : mpg123.exe, soundstretch.exe
'------------------------------------------------------------------------------------------------------------------------
' Decompress an mp3 file to wav with the mpg123 decoder (mpg123.exe), mpg123 is faster than any other decoder
' Next, change the speed (tempo) of the wav file with soundstretch (soundstretch.exe), very slow speed will take more time
' mp3towav.wav        : decompressed file
' wavspeed.wav        : file with speed changed
' temp1.txt, temp2.txt : temporary files that will be deleted, make sure you don't have important files with these names
'---------------------------------------------------------------------
'------------- Files that will be deleted if exist -------------------
If _FileExists("mp3towav.wav") = -1 Then Kill ("mp3towav.wav")
If _FileExists("wavspeed.wav") = -1 Then Kill ("wavspeed.wav")
If _FileExists("temp1.txt") = -1 Then Kill ("temp1.txt")
If _FileExists("temp2.txt") = -1 Then Kill ("temp2.txt")
'---------------------------------------------------------------------
mp3file$ = "Silent Night.mp3" ' File to change speed
Lowquality = 1 '  ----  1 : Low quality (faster),  0 : High quality (a little slower)
Tempospeed = 20 '  ----  10 : Normal speed, no need to decode,  Less that 10 : Slower speed,  More than 10 : Faster speed
tempo$ = LTrim$(RTrim$(Str$((Tempospeed - 10) * 10)))

If Lowquality = 1 Then
    b1$ = "mpg123 -2 -w " + Chr$(34) + "mp3towav.wav" + Chr$(34) + " " + Chr$(34) + mp3file$ + Chr$(34)
    b3$ = "soundstretch " + Chr$(34) + "mp3towav.wav" + Chr$(34) + " " + Chr$(34) + "wavspeed.wav" + Chr$(34) + " -tempo=" + tempo$ + " -speech -naa" '-quick, not mutch faster
Else
    b1$ = "mpg123 -w " + Chr$(34) + "mp3towav.wav" + Chr$(34) + " " + Chr$(34) + mp3file$ + Chr$(34)
    b3$ = "soundstretch " + Chr$(34) + "mp3towav.wav" + Chr$(34) + " " + Chr$(34) + "wavspeed.wav" + Chr$(34) + " -tempo=" + tempo$ + " -speech"
End If
b2$ = "echo tempfiletext  > " + Chr$(34) + "temp1.txt" + Chr$(34)
b4$ = "echo tempfiletext  > " + Chr$(34) + "temp2.txt" + Chr$(34)

Open "decode.bat" For Output As #1
Print #1, "@echo off"
Print #1, b1$
Print #1, b2$
Print #1, b3$
Print #1, b4$
Close #1
_Delay 1

If _FileExists("decode.bat") = -1 Then
    Print "File decode.bat created"
    Shell _DontWait _Hide "decode.bat"
Else
    Print "Can't create file decode.bat": GoTo TheEnd
End If

If _FileExists("temp1.txt") = 0 Then Print "Decoding..."
k1 = 0

Do
    If _FileExists("temp1.txt") = -1 Then Print "Changing Speed..."
    If _FileExists("temp2.txt") = -1 Then Print "Done...": Exit Do
    k1 = k1 + 1
    If k1 = 10 Then Print "Taking too long..."
    If k1 = 13 Then Print "Aborting in...3 seconds"
    If k1 = 16 Then Print "Aborting": Exit Do
    _Delay 1
Loop Until k1 > 15

If _FileExists("wavspeed.wav") = -1 Then
    Print "File wavspeed.wav created"
    Print "Playing file wavspeed.wav"
    music2& = 0
    music2& = _SndOpen("wavspeed.wav")
    If music2& <> 0 Then
        _SndVol music2&, .8
        _SndPlay music2&
    End If
Else
    Print "wavspeed.wav not created"
End If

Print
Print "Press any key to exit"
Do
Loop Until InKey$ <> ""

TheEnd:
If _SndPlaying(music2&) <> 0 Then _SndStop (music2&): _SndClose (music2&)

System
End


Attached Files
.zip   mp3 speed.zip (Size: 1.87 MB / Downloads: 23)
Reply


Messages In This Thread
Mp3 Speed - by 2112 - 12-08-2025, 08:07 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)