Search the Community
Showing results for tags 'play backwards'.
-
hey, having a problem understanding bass udf, i can get the audio to play with _BASS_FX_ReverseCreate, forward and backwards, with the reverse BASS_FX_RVS_REVERSE and BASS_FX_RVS_FORWARD settings, or i can get the audio to play with _BASS_FX_TempoCreate, forward and modifying the pitch and tempo, overlap secs, and so on, but i cant get them to work togheter, any idea on how to make them work together? i tried something on line 115 but didn't work, and have no idea on how to do it, any tips? #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <Bass.au3> #include <BassConstants.au3> #include <BassFX.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Progress_A Global $Progress_B #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 438, 192, 124) _GUICtrlCreateProgress(5, 5, 605, 10) $BTNPosLeft = 5 $BTNPosTop = 20 $BTNplay = GUICtrlCreateButton(chrw(9654), $BTNPosLeft, $BTNPosTop, 51, 25) GUICtrlSetFont(-1, 18, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 $BTNStop = GUICtrlCreateButton(chrw(9632), $BTNPosLeft, $BTNPosTop, 51, 25) GUICtrlSetFont(-1, 10, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 $BTNpause = GUICtrlCreateButton(chrw(9646)&chrw(9646), $BTNPosLeft, $BTNPosTop, 51, 25) ;9646 GUICtrlSetFont(-1, 11, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 $BTNReverse = GUICtrlCreateButton(chrw(9664), $BTNPosLeft, $BTNPosTop, 51, 25) GUICtrlSetFont(-1, 18, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 GUISetState(@SW_SHOW) $BTNPosLeft = 5 $BTNTempoUp = GUICtrlCreateButton("TempUp", $BTNPosLeft, $BTNPosTop+30, 51, 25) GUICtrlSetFont(-1, 10, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 $BTNTempoDn = GUICtrlCreateButton('TempDn', $BTNPosLeft, $BTNPosTop+30, 51, 25) GUICtrlSetFont(-1, 10, 0, 0, "MS Sans Serif") $BTNPosLeft += 51 ;~ $BTNTest #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Global $playing_state = -1 ;Startup Bass & BassFX. Also check if loading failed. _BASS_STARTUP ("BASS.dll") If @error = -1 Then MsgBox (0, "", "DLL Does not exist? Please check file exists.") Exit EndIf _BASS_FX_Startup("bass_fx.dll") If @error = -1 Then MsgBox (0, "", "DLL Does not exist? Please check file exists.") Exit EndIf ;Initalize bass. Required for most functions. _BASS_Init(0, -1, 44100, 0, "") ;Check if bass iniated. If not, we cannot continue. If @error Then MsgBox(0, "Error", "Could not initialize audio") Exit EndIf ;Prompt the user to select a MP3 file $file = FileOpenDialog("Open...", "", "MP3 Files (*.*)") $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, $BASS_STREAM_DECODE) ;Check if we opened the file correctly. If @error Then MsgBox(0, "Error", "Could not load audio file" & @CR & "Error = " & @error) Exit EndIf ;Get the length of the song in bytes. $song_length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE) ;~ ConsoleWrite ('$song_length='&$song_length&@lf) $song_length_Sec = _BASS_ChannelBytes2Seconds($MusicHandle, $song_length) ;~ ConsoleWrite ('$song_length_Sec='&$song_length_Sec&@lf) ConsoleWrite ('>Time = '&StringFormat("%02d", floor($song_length_Sec/60))&':'&StringFormat("%02d", round($song_length_Sec-(60*floor($song_length_Sec/60))))&''&@lf) ;~ ;TEST WITH ONLY REVRESE $tempo = _BASS_FX_ReverseCreate ($MusicHandle, 10, 0) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_REVERSE) ;TEST WITH ONLY Tempo ;~ $tempo = _BASS_FX_TempoCreate ($MusicHandle, 0) ;~ _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_REVERSE) ;Test with reverse Tempo ;~ $Reverse = _BASS_FX_TempoCreate ($MusicHandle, 0) ;~ _BASS_ChannelSetAttribute ($Reverse, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_REVERSE) ;~ $tempo = _BASS_FX_ReverseCreate ($Reverse, 10, 0) ;~ _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_REVERSE) $current = _BASS_ChannelGetPosition($tempo, $BASS_POS_BYTE) ConsoleWrite ('1'&@lf) $tempoSpeed = 0 While 1 ;~ ConsoleWrite ('X'&@lf) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _BASS_Free() Exit Case $BTNplay _BASS_ChannelPause($tempo) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_FORWARD) _BASS_ChannelPlay($tempo, 0) Case $BTNStop _BASS_ChannelStop($tempo) Case $BTNpause _BASS_ChannelPause($tempo) Case $BTNReverse _BASS_ChannelPause($tempo) _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_REVERSE_DIR, $BASS_FX_RVS_REVERSE) _BASS_ChannelPlay($tempo, 0) Case $BTNTempoUp $tempoSpeed += 5 _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, $tempoSpeed) ConsoleWrite ('$tempoSpeed='&$tempoSpeed&@lf) Case $BTNTempoDn $tempoSpeed -= 5 _BASS_ChannelSetAttribute ($tempo, $BASS_ATTRIB_TEMPO, $tempoSpeed) ConsoleWrite ('$tempoSpeed='&$tempoSpeed&@lf) EndSwitch Sleep(20) ;Get the current position in bytes $current = _BASS_ChannelGetPosition($tempo, $BASS_POS_BYTE) Local $pos_A = ControlGetPos ('','',$Progress_A) $X_position = $current/($song_length/$pos_A[2]-2) ;~ ConsoleWrite ('!$X_position= '&$X_position&@lf) _GUICtrlSetProgress( $X_position) WEnd func _GUICtrlSetProgress($data) Local $pos_A = ControlGetPos ('','',$Progress_A) Local $pos_B = ControlGetPos ('','',$Progress_B) If $data > $pos_A[2]-2 then $data = $pos_A[2]-2 ControlMove('','',$Progress_B,$pos_B[0],$pos_B[1],$data,$pos_B[3]) EndFunc Func _GUICtrlCreateProgress($left, $top , $width , $height ) $Progress_A = GUICtrlCreateLabel("", $left+1, $top+1, $width-1, $height-1) GUICtrlSetBkColor(-1, 0xCCCCCC) GUICtrlSetState(-1, $GUI_DISABLE) $Progress_B = GUICtrlCreateLabel("", $left+2, $top+2, $width-3 , $height-3) GUICtrlSetBkColor(-1, 0x888888) GUICtrlSetState(-1, $GUI_DISABLE) $GR_Top = GUICtrlCreateGraphic($left, $top, 0, 0) ;~ GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000FF) GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 0) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $width+1, 0) $GR_Bot = GUICtrlCreateGraphic($left, $top+$height, 0, 0) ;~ GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000FF) GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 0) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $width+1, 0) $GR_Bot = GUICtrlCreateGraphic($left, $top, 0, 0) ;~ GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000FF) GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, 0) GUICtrlSetGraphic(-1, $GUI_GR_LINE, 0, $height) $GR_Bot = GUICtrlCreateGraphic($left, $top, 0, 0) ;~ GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000FF) GUICtrlSetGraphic(-1, $GUI_GR_MOVE, $width, 0) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $width, $height) EndFunc Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) ; Check control under cursor $aCInfo = GUIGetCursorInfo($Form1) ;~ $aCInfo = GUIGetCursorInfo() ConsoleWrite ('$aCInfo[0]= '&$aCInfo[0]&@lf) ConsoleWrite ('$aCInfo[1]= '&$aCInfo[1]&@lf) ConsoleWrite ('$aCInfo[2]= '&$aCInfo[2]&@lf) ConsoleWrite ('$aCInfo[3]= '&$aCInfo[3]&@lf) ConsoleWrite ('$aCInfo[4]= '&$aCInfo[4]&@lf) If $aCInfo[4] = $Progress_A or $aCInfo[4] = $Progress_B Then $aBar= ControlGetPos ("","",$Progress_A) $X_position = $aCInfo[0]-$aBar[0] ConsoleWrite ('!$X_position= '&$X_position&@lf) _GUICtrlSetProgress( $X_position) Local $pos_A = ControlGetPos ('','',$Progress_A) $ChannelSetPosition= $X_position*($song_length/$pos_A[2]-2) _BASS_ChannelSetPosition($tempo,$ChannelSetPosition,$BASS_POS_BYTE) EndIf EndFunc ;==>_WM_LBUTTONDOWN Func OnAutoItExit() ;Free Resources _BASS_Free() EndFunc ;==>OnAutoItExit Edit: sorry, posted in the wrong area, Please move my post to general help and support
- 2 replies
-
- play forward
- play backwards
-
(and 2 more)
Tagged with: