Jump to content
Sign in to follow this  
nacerbaaziz

easy audio player progect

Recommended Posts

hellow guys
I am a blind young man
I started a project to make an audio player
with recorder
I ended the player and i did not know how to recorder
This player is Compatible with the blind and visually impaired and ordinary users
Unfortunately I do not see so I could not merge images and icons

So I hope you will be able to help me in this matter

I will bring you the open source project and please help me to add images, icons and recorder, the project is requires easy access in order to be compatible with the screen readers, Please take this into account.
the software is organized so the recorder is In a special  menu that Contains stop and start and pause and save.
The same is true for player
Please help
And greetings to all

easy player.zip

Share this post


Link to post
Share on other sites

Thanks for this script.  It was a lot of fun.  The script is doing things that I want to know how to do.  Your examples will help me quickly learn how to do this stuff. :)

(Things that probably aren't an issue anymore)

Spoiler

In easyPlayer.au3: Code had scope issues due to order of includes.  

I replaced Include FileOptions.au3 with File.au3.  Rewrote _FileGetDirPath, _GetFileName using _PathSplit() this was just to make it work.  I'm not sure my changes are the right way to go about things.

In options.au3: $Color_Green was giving me warnings replaced with 0x00C000.

 

Here is an updated example of easyPlayer.au3 in case anyone else wants to pickup with this running at default AutoIt settings.

#RequireAdmin
#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#AutoIt3Wrapper_Res_Comment=easy player
#AutoIt3Wrapper_Res_Description=easy player
#AutoIt3Wrapper_Res_Fileversion=1.5.0.22
#AutoIt3Wrapper_Res_Fileversion_AutoIncrement=y
#AutoIt3Wrapper_Res_LegalCopyright=2017, by nacer baaziz
#AutoIt3Wrapper_Res_Language=1033
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Global $sound = "", $MusicHandle, $reverb = false, $echo = false, $Chorus = false, $Reverse = false, $ReverbHandle, $EchoHandle, $ChorusHandle, $param

#######
#include <include\Bass.au3>
#include <include\BassConstants.au3>
#include <include\BassFX.au3>
#include <GUIConstants.au3>
#include <File.au3>
#include <include\restart.au3>
#include <include\func.au3>
#include <include\options.au3>
#include <include\Sec2Time.au3>
#include <include\languages.au3>
#include <ColorConstantS.au3>
#include <SliderConstants.au3>
#include <Sound.au3>
#include <ToolTipConstants.au3>
#include <UpDownConstants.au3>
#include <MenuConstants.au3>
#include <MsgBoxConstants.au3>

#include <ProgressConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListBox.au3>
;#include <FileOptions.au3>
########
Opt("GUICloseOnESC", 0)
main()
func main()
    _BASS_Startup(@scriptDir & "\dll\bass.dll")
    If @error = -1 Then
        MsgBox (0, "", "DLL Does not exist?  Please check file exists.")
        Exit
    EndIf

    _BASS_FX_Startup(@scriptDir & "\dll\bass_fx.dll")
    If @error = -1 Then
        MsgBox (0, "", "DLL Does not exist?  Please check file exists.")
        Exit
    EndIf
    _BASS_Init(0, -1, 44100, 0, "")
    If @error Then
        MsgBox(0, "Error", "Could not initialize audio")
        Exit
    EndIf

    ;global $sound = "", $MusicHandle, $reverb = false, $echo = false, $Chorus = false, $Reverse = false, $ReverbHandle, $EchoHandle, $ChorusHandle, $param
    global $file = False, $dir = 0, $filePos
    global $volume = ""
    $volume = RegRead("HKEY_CURRENT_USER\SOFTWARE\easy audio player", "volume")
    if @error then
    $volume = INIRead(@scriptdir&"settings.ini", "settings", "volume", "")
    If @Error then
    $volume = 50
    endIf
    _BASS_ChannelSetVolume($MusicHandle, $volume)
    endIf

    Global $Playing = False, $state = false
    global $sFilePath
    global $vlm = ""
    GUICreate("2")
    global $List = GUICtrlCreateList("", -1, -1, -1, -1)

    ###### command line ######
    If $CmdLine[0] = 0 Then
    $file = False
    ElseIf $CmdLine[0] = 1 Then
    $File = $CmdLine[1]
    $dir = _FileGetDirPath($file)
        _GUICtrlListBox_BeginUpdate($List)
        _GUICtrlListBox_Dir($List, $dir & "\*.mp3")
        _GUICtrlListBox_Dir($List, $dir & "\*.wav")
        _GUICtrlListBox_Dir($List, $dir & "\*.ogg")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp1")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp2")
        _GUICtrlListBox_Dir($List, $dir & "\*.m3u")
        _GUICtrlListBox_Dir($List, $dir & "\*.pls")

        _GUICtrlListBox_endUpdate($List)
    _GUICtrlListBox_SelectString($list, _GetFileName($file))

    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    else
       Switch $CmdLine[1]
    Case "-play"

    $File = $CmdLine[2]
    $dir = _FileGetDirPath($file)
        _GUICtrlListBox_BeginUpdate($List)
        _GUICtrlListBox_Dir($List, $dir & "\*.mp3")
        _GUICtrlListBox_Dir($List, $dir & "\*.wav")
        _GUICtrlListBox_Dir($List, $dir & "\*.ogg")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp1")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp2")
        _GUICtrlListBox_Dir($List, $dir & "\*.m3u")
        _GUICtrlListBox_Dir($List, $dir & "\*.pls")

        _GUICtrlListBox_endUpdate($List)
    _GUICtrlListBox_SelectString($list, _GetFileName($file))

    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    $Playing = True
    case else
    $file = $file
    endSwitch
    endIf
    ####### command line end #######
    ### check ###
    if not fileExists(@scriptdir & "\" & StringTrimRight(@scriptName, 4) & ".ini") then
    Opt("GUICloseOnESC", 1)
    Options()
    _scriptRestart()
    endIf
        Local $hGUI = GUICreate(_t("10"), 1000, 700)
        GUISetBkColor($COLOR_RED)

    ######### menu bar #######
    $FileMenu = GUICtrlCreateMenu(_t("100"))
        GUICtrlSetBkColor(-1, 0x8080ff)
    #######
    local $opene = GUICtrlCreateMenuItem(_t("101") & "... (ctrl+o)", $FileMenu)
        GUICtrlSetBkColor(-1, 0x8080ff)
    local $openURL = GUICtrlCreateMenuItem("open an url...", $FileMenu)
    local $explore = GUICtrlCreateMenuItem(_t("103") & "... (ctrl+e)", $FileMenu)
    local $ExitItem = GUICtrlCreateMenuItem(_t("102"), $FileMenu)
    #######
    local   $playMenu = GUICtrlCreateMenu(_t("200"))
    ####
    local $play = GUICtrlCreateMenuItem(_t("201") & "... (space)", $playMenu)

    local $stop = GUICtrlCreateMenuItem(_t("202") & "... (ctrl+space)", $playMenu)

    local $FORWARD = GUICtrlCreateMenuItem(_t("203") & "... (right key)", $playMenu)

    local $rearward = GUICtrlCreateMenuItem(_t("204") & "... (left key)", $playMenu)
    local $goto = GUICtrlCreateMenuItem(_t("210") & "... (ctrl+g)", $playMenu)
    local $up = GUICtrlCreateMenuItem(_t("205") & "... (up key)", $playMenu)
    local $down = GUICtrlCreateMenuItem(_t("206") & "... (down key)", $playMenu)
    local $fast = GUICtrlCreateMenuItem("faster", $playMenu)
    local $slow = GUICtrlCreateMenuItem("slowly", $playMenu)
    local $next = GUICtrlCreateMenuItem(_t(208) & "... (tab)", $playMenu)
    local $back = GUICtrlCreateMenuItem(_t(209) & "... (shift+tab)", $playMenu)
    ###
    local $efectMenu = GUICtrlCreateMenu(_t(300))
    local $rev = GUICtrlCreateMenuItem(_t(301) & "...", $efectMenu)
    local $ech = GUICtrlCreateMenuItem(_t(302) & "...", $efectMenu)
    local $chor = GUICtrlCreateMenuItem(_t(303) & "...", $efectMenu)

    ########
    local $toolsmenu = GUICtrlCreateMenu(_t("400"))
    ###########
    local $options = GUICtrlCreateMenuItem(_t("401"), $toolsMenu)
    local $recorderMe = GUICtrlCreateMenuItem("go to recorder mod...", $toolsMenu)
    ##########
    local $helppMenu = GUICtrlCreateMenu(_t("500"))
    ####

    ###
    ##########  menu bar end########
    ###label #####

    local $Label = GUICtrlCreateLabel("", 50, 80, 300, 70)

        GUICtrlSetBkColor(-1, 0xffffff)
    local $My = GUICtrlCreateLabel("welcom to easy player", 50, 10, 150, 50)
    local $Label1 = GUICtrlCreateLabel("00:00:00 / 00:00:00" & @crlf & "0%", 50, 120, 200, 70)
        GUICtrlSetBkColor(-1, 0x5ffffff)


    local $play2 = GUICtrlCreateLabel("play", 0, 200, 100, 50)
    local $stop2 = GUICtrlCreateLabel("stop", 350, 200, 100, 50)
    local $up2 = GUICtrlCreateLabel("volume(up)", 0, 250, 100, 50)
    local $down2 = GUICtrlCreateLabel("volume(down)", 350, 250, 100, 50)
    local $FORWARD2 = GUICtrlCreateLabel("FORWARD", 0, 300, 100, 50)
    local $reaRWARD2 = GUICtrlCreateLabel("reaRWARD", 350, 300, 100, 50)
    local $next2 = GUICtrlCreateLabel("next", 0, 360, 100, 50)

    local $back2 = GUICtrlCreateLabel("back", 350, 360, 100, 50)


    ########### label end########
    $hrecorder = GUICreate("recorder", 700, 700)
    GUICtrlCreateLabel("welcom to audio recorder" & @crlf & "please select your microphone and press start to begin recording." & @crlf & "if you want to stop it press stop, or press pause to pause the recorde." & @crlf & "when you finish your record press save to get your audio file.", 50, 10, 500, 100)
    GUICtrlCreateLabel("microphone", 100, 90, 100, 50)
    $microphone = GUICtrlCreateCombo("", 100, 100, 150, 50, $CBS_DROPDOWNList)
    $rstart = GUICtrlCreateButton("&start", 0, 200, 50, 50)
    $rstop = GUICtrlCreateButton("&stop", 150, 200, 50, 50)
    if $file then
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
        GUISetState(@SW_SHOW, $hGUI)
    $volume = RegRead("HKEY_CURRENT_USER\SOFTWARE\easy audio player", "volume")
    if @error then
    $volume = INIRead(@scriptdir&"settings.ini", "settings", "volume", "")
    If @Error then
    $volume = 50
    endIf
    _BASS_ChannelSetVolume($MusicHandle, $volume)
    endIf

    dim $aAccelKeys = [["^o", $opene], ["{space}", $play], ["{up}", $up], ["{down}", $down], ["{right}", $FORWARD], ["{left}", $rearward], ["^+o", $options], ["{tab}", $next], ["+{tab}", $back], ["{enter}", $play], ["!{left}", $back], ["!{right}", $next], ["^{space}", $stop], ["^g", $goto], ["^e", $explore], ["r", $rev], ["e", $ech], ["c", $chor], ["n", $next], ["b", $back], ["^u", $openURL], ["{MEDIA_NEXT}", $next], ["{MEDIA_PREV}", $back], ["{MEDIA_STOP}", $stop], ["{MEDIA_PLAY_PAUSE}", $play]]
        GUISetAccelerators($aAccelKeys, 0)
        While 1


        GUISetAccelerators($aAccelKeys, 0)

            Switch GUIGetMsg()
                Case $GUI_EVENT_CLOSE, $exititem
    _BASS_ChannelStop($MusicHandle)
        _BASS_Free()
                    Exit
    case $explore
    $oPath = _fileGetDirPath($file)
    ShellExecute("explorer.exe","/select, " & $oPath & GUICtrlRead($list))

    case $up, $up2
    if $volume >= 100 then
    $vlm = 100
    else
    $vlm = $volume+10
    endIf
    $volume = $vlm
    INIWrite(@scriptDir&"\" & StringTrimRight(@scriptName, 4) & ".ini", "settings", "volume", $vlm)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\easy audio player", "volume", "REG_SZ", $vlm)
    _BASS_ChannelSetVolume($MusicHandle, $vlm)

    case $down, $down2

    if $volume <= 0 then
    $vlm = 0
    else
    $vlm = $volume-10
    endIf
    $volume = $vlm
    INIWrite(@scriptDir&"\" & StringTrimRight(@scriptName, 4) & ".ini", "settings", "volume", $vlm)
    RegWrite("HKEY_CURRENT_USER\SOFTWARE\easy audio player", "volume", "REG_SZ", $vlm)
    _BASS_ChannelSetVolume($MusicHandle, $vlm)


                Case $play, $play2
    if not $file then
    $Fileopen = FileOpenDialog("Select Audio file","","Sound Files(*.mp1;*.mp2;*.mp3;*.wav;*.ogg;*.m3u;*.pls)|All siported Files(*.*)")
    if not @error then
    $file = $fileOpen
    $dir = _FileGetDirPath($file)
        _GUICtrlListBox_BeginUpdate($List)
        _GUICtrlListBox_Dir($List, $dir & "\*.mp3")
        _GUICtrlListBox_Dir($List, $dir & "\*.wav")
        _GUICtrlListBox_Dir($List, $dir & "\*.ogg")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp1")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp2")
        _GUICtrlListBox_Dir($List, $dir & "\*.m3u")
        _GUICtrlListBox_Dir($List, $dir & "\*.pls")
        _GUICtrlListBox_endUpdate($List)
    _GUICtrlListBox_SelectString($list, _GetFileName($file))
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetDevice($MusicHandle, 1)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    autoefect()
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    msgbox(16, "error", @error)
    else
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    GUICtrlSetData($PLAy,_t(207) & "... (space)")
    GUICtrlSetData($PLAy2,"&pause")
    $Playing = True
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))

    endIf



    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    else
    SWITCH _BASS_ChannelIsActive($MusicHandle)
    case 0
    _BASS_ChannelSetDevice($MusicHandle, 1)
    _BASS_ChannelSetvolume($MusicHandle, $volume)

    _BASS_ChannelPlay($MusicHandle, 1)
    GUICtrlSetData($PLAy,_t(207) & "... (space)")
    GUICtrlSetData($PLAy2,"&pause")

    $Playing = True

    case 1
    _BASS_ChannelPause($MusicHandle)
    GUICtrlSetData($PLAY,_t(201) & "... (space)")
    GUICtrlSetData($PLAY2,"play")
    $Playing = False

    case 3
    _BASS_ChannelSetDevice($MusicHandle, 1)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 0)
    GUICtrlSetData($PLAy,_t(207) & "... (space)")
    GUICtrlSetData($PLAy2,"&pause")

    $Playing = True

    case else
    $Fileopen = FileOpenDialog("Select Audio file","","Sound Files(*.mp1;*.mp2;*.mp3;*.wav;*.ogg;*.m3u;*.pls)|All siported Files(*.*)")
    if not @error then
    $file = $fileOpen
    $dir = _FileGetDirPath($file)
        _GUICtrlListBox_BeginUpdate($List)
        _GUICtrlListBox_Dir($List, $dir & "\*.mp3")
        _GUICtrlListBox_Dir($List, $dir & "\*.wav")
        _GUICtrlListBox_Dir($List, $dir & "\*.ogg")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp1")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp2")
        _GUICtrlListBox_Dir($List, $dir & "\*.m3u")
        _GUICtrlListBox_Dir($List, $dir & "\*.pls")

        _GUICtrlListBox_endUpdate($List)
    _GUICtrlListBox_SelectString($list, _GetFileName($file))
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetDevice($MusicHandle, 1)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    autoefect()
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    msgbox(16, "error", @error)
    endIf
    GUICtrlSetData($PLAy,_t(207) & "... (space)")
    GUICtrlSetData($PLAy2,"&pause")
    $Playing = True

    endIf
    endSwitch
    endIf
    case $opene

    $Fileopen = FileOpenDialog("Select Audio file","","Sound Files(*.mp1;*.mp2;*.mp3;*.wav;*.ogg;*.m3u;*.pls)|All siported Files(*.*)")
    if not @error then
    $file = $fileOpen
    $dir = _FileGetDirPath($file)
        _GUICtrlListBox_BeginUpdate($List)
        _GUICtrlListBox_Dir($List, $dir & "\*.mp3")
        _GUICtrlListBox_Dir($List, $dir & "\*.wav")
        _GUICtrlListBox_Dir($List, $dir & "\*.ogg")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp1")
        _GUICtrlListBox_Dir($List, $dir & "\*.mp2")
        _GUICtrlListBox_Dir($List, $dir & "\*.m3u")
        _GUICtrlListBox_Dir($List, $dir & "\*.pls")

        _GUICtrlListBox_endUpdate($List)
    _GUICtrlListBox_SelectString($list, _GetFileName($file))

    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetDevice($MusicHandle, 1)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    autoefect()
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    msgbox(16, "error", _BASS_ErrorGetCode())
    else
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    GUICtrlSetData($PLAy,_t(207) & "... (space)")
    GUICtrlSetData($PLAy2,"&pause")
    $Playing = True
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))

    endIf

    endIf
    case $openUrl
    $url = InputBox("play an url audio", "enter the file url")
    if not @error then
    $MusicHandle = _BASS_StreamCreateURL($url, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    autoefect()
    _BASS_ChannelPlay($MusicHandle, 0)
    $file = $url
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    Case $STOP, $stop2
    GUICtrlSetData($PLAY,_t("201") & "... (space)")
    GUICtrlSetData($PLAY2,"play")
    $Playing = False
    _BASS_ChannelStop($MusicHandle)
    _BASS_ChannelSetPosition($MusicHandle, 0, $BASS_POS_BYTE)
    GUICtrlSetData($label1, _Sec2Time(Round(_BASS_ChannelBytes2Seconds($MusicHandle, _BASS_ChannelGetPosition($MusicHandle, 0)))) & " / " & _sec2Time(Round(_BASS_ChannelBytes2Seconds($MusicHandle, _BASS_ChannelGetLength($MusicHandle, 0)))) & @crlf & Round((_BASS_ChannelGetPosition($MusicHandle, 0) / _BASS_ChannelGetLength($MusicHandle, 0)) * 100, 0) & "%")
    Case $rearward, $rearward2
    $pos = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
    if $pos < _BASS_ChannelSeconds2Bytes($MusicHandle, 5) then
    _BASS_ChannelSetPosition($MusicHandle, 0, $BASS_POS_BYTE)
    else
    _BASS_ChannelSetPosition($MusicHandle, $pos-_BASS_ChannelSeconds2Bytes($MusicHandle, 5), $BASS_POS_BYTE)
    endIf
    Case $FORWARD, $FORWARD2

    $pos = _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)
    $length = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE)
    if $pos+_BASS_ChannelSeconds2Bytes($MusicHandle, 5) >= $length then
    _BASS_ChannelSetPosition($MusicHandle, $length, $BASS_POS_BYTE)
    else
    _BASS_ChannelSetPosition($MusicHandle, $pos+_BASS_ChannelSeconds2Bytes($MusicHandle, 5), $BASS_POS_BYTE)
    endIf
    case $goto
    GUISetState(@sw_hide, $hGUI)
    Opt("GUICloseOnESC", 1)
    $sPosition = Round(_BASS_ChannelBytes2Seconds($MusicHandle, _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE)))

    $goToDo = _goto($sPosition)

    if $goToDo = $sPosition then
    $GoToDo = false
    $sPosition = false

    else
    _BASS_ChannelSetPosition($MusicHandle, _BASS_ChannelSeconds2Bytes($MusicHandle, $GoToDo), $BASS_POS_BYTE)
    $GoToDo = false
    $sPosition = false

    endIf
    Opt("GUICloseOnESC", 0)
    GUISetState(@sw_show, $hGUI)
    case $my
    MSGBox(0, "about apps", "this app is an small tool which help you to play your audio files" & @crlf & "this app is devloped by nacer baaziz")
    case $next, $next2
    if $file then

    $filePos = $file
    $all = StringReplace(_GUICtrlListBox_GetCount($list), " ", "")
    $pushd = StringReplace(_GUICtrlListBox_GetCurSel($list), " ", "")

    if $pushd = $all-1 then
    $pushd = 0
    $text = _GUICtrlListBox_GetText($list, $pushd)
    _GUICtrlListBox_setCurSel($list, $pushd)
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $Dir & $text, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    else
    $file = $Dir & $text
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    autoEfect()
    else

    $text = _GUICtrlListBox_GetText($list, $pushd+1)
    _GUICtrlListBox_setCurSel($list, $pushd+1)
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $Dir & $text, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    else

    $file = $Dir & $text
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    autoEfect()
    endIf

    endIf
    case $Back, $back2
    if $file then
    $all = _GUICtrlListBox_GetCount($list)
    $pushd = _GUICtrlListBox_GetCurSel($list)
    if $pushd = 0 then
    $pushd = $all
    endIf
    $text = _GUICtrlListBox_GetText($list, $pushd-1)
    _GUICtrlListBox_setCurSel($list, $pushd-1)
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $Dir & $text, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelSetvolume($MusicHandle, $volume)
    _BASS_ChannelPlay($MusicHandle, 1)
    else

    $file = $Dir & $text
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    autoEfect()
    endIf
    case $rev
                If not $reverb then
                    _BASS_FXSetParameters($ReverbHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $ReverbHandle)
                    $ReverbHandle = _BASS_ChannelSetFX($MusicHandle, $BASS_FX_DX8_REVERB, 7)

                    _BASS_FXSetParameters($ReverbHandle, "2|-8|3000|0.010")
    $reverb = true
    GUICtrlSetState($rev, $GUI_checked)
                Else
                    _BASS_FXSetParameters($ReverbHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $ReverbHandle)


    $reverb = false
    GUICtrlSetState($rev, $GUI_unchecked)
                EndIf
    case $ech
                If not $echo Then
                    _BASS_FXSetParameters($EchoHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $EchoHandle)
                    $EchoHandle = _BASS_ChannelSetFX($MusicHandle, $BASS_FX_BFX_ECHO2, 6)
                    _BASS_FXSetParameters($EchoHandle, "0")
                    _BASS_FXSetParameters($EchoHandle, "1|0.3|0.4|1|" & $BASS_BFX_CHANALL)
    $echo = true
    GUICtrlSetState($ech, $GUI_checked)
                Else
                    _BASS_FXSetParameters($EchoHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $EchoHandle)
    $echo = false
    GUICtrlSetState($ech, $GUI_unchecked)
                EndIf
    case $Chor
                If not $Chorus then
                    _BASS_FXSetParameters($ChorusHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $ChorusHandle)
                    $ChorusHandle = _BASS_ChannelSetFX($MusicHandle, $BASS_FX_BFX_CHORUS, 5)
                    $param = _BASS_FXGetParameters($ChorusHandle)

                    _BASS_FXSetParameters($ChorusHandle, "1|0.6|0.2|2|11|4|" & $BASS_BFX_CHANALL)
    $Chorus = true
    GUICtrlSetState($chor, $GUI_checked)
                Else
                    _BASS_FXSetParameters($ChorusHandle, "0")
                    _BASS_ChannelRemoveFX($MusicHandle, $ChorusHandle)
    $Chorus = false
    GUICtrlSetState($chor, $GUI_unchecked)
                EndIf
    case $fast
    local $t = 0



    local $t2 = _BASS_ChannelSetAttribute ($MusicHandle, $BASS_ATTRIB_TEMPO, $t+10)
    $t = $t2
    case $recorderMe
    GUISetState(@sw_hide, $hGUI)
    GUISetState(@sw_show, $HRecorder)
    case $options
    Opt("GUICloseOnESC", 1)
        GUISetState(@SW_hide, $hGUI)
    $return = options()
    if $return = 1 then
    $answer = MSGBox(4, "the settings has been changed", "to apply the new settings you must to restart your application, do you want to restart it now? press yes to restart it now or no to restart it later")
    switch $answer
    case 6
    _scriptRestart()
    case 7
    Opt("GUICloseOnESC", 0)
        GUISetState(@SW_show, $hGUI)
    endSwitch
    else
    Opt("GUICloseOnESC", 0)
        GUISetState(@SW_show, $hGUI)
    endIf

            EndSwitch
    if _BASS_ChannelIsActive($MusicHandle) = 1 and $file then
    GUICtrlSetData($label1, _Sec2Time(Round(_BASS_ChannelBytes2Seconds($MusicHandle, _BASS_ChannelGetPosition($MusicHandle, 0)))) & " / " & _sec2Time(Round(_BASS_ChannelBytes2Seconds($MusicHandle, _BASS_ChannelGetLength($MusicHandle, 0)))) & @crlf & Round((_BASS_ChannelGetPosition($MusicHandle, 0) / _BASS_ChannelGetLength($MusicHandle, 0)) * 100, 0) & "%")
    endIf
    if $file then
    if _BASS_ChannelGetPosition($MusicHandle, $BASS_POS_BYTE) = _BASS_ChannelGetLength($MusicHandle, $BASS_POS_BYTE) then
    Sleep(500)
    $all = StringReplace(_GUICtrlListBox_GetCount($list), " ", "")
    $pushd = StringReplace(_GUICtrlListBox_GetCurSel($list), " ", "")

    if $pushd = $all-1 then
    $pushd = 0
    $text = _GUICtrlListBox_GetText($list, $pushd)
    _GUICtrlListBox_setCurSel($list, $pushd)
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $Dir & $text, 0, 0, 0)
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelPlay($MusicHandle, 1)
    else

    $file = $Dir & $text
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    autoEfect()
    elseif $pushd = $all then
    _BASS_ChannelPlay($MusicHandle, 1)
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    else
    $text = _GUICtrlListBox_GetText($list, $pushd+1)
    _GUICtrlListBox_setCurSel($list, $pushd+1)
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $Dir & $text, 0, 0, 0)
    _BASS_ChannelPlay($MusicHandle, 1)
    if @error then
    _BASS_ChannelStop($MusicHandle)
    $MusicHandle = _BASS_StreamCreateFile(False, $file, 0, 0, 0)
    _BASS_ChannelPlay($MusicHandle, 1)
    else

    $file = $Dir & $text
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    winSetTitle($hGUI, "", _t(10) & " : " & _GetFileName($file))
    endIf
    autoEfect()
    endIf
    endIf
    endIf
    if $file then
    switch _BASS_ChannelIsActive($MusicHandle)
    case 1
    if $state = 1 then
    $state = 1
    else
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " in progress")
    $state = 1
    endIf
    case 0
    if $state = 0 then
    $state = 0
    else
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " stoped")
    $state = 0
    endIf
    case 3
    if $state = 3 then
    $state =3
    else
    GUICtrlSetData($label, @crlf & _GetFileName($file) & @crlf & " on pause")
    $state =3
    endIf
    endSwitch
    endIf
        WEnd

        ; Delete the previous GUI and all controls.
        GUIDelete($hGUI)
EndFunc; main

Func _FileGetDirPath($sPath)
    Local $sDrive = "", $sDir = "", $sFilename = "", $sExt = ""

    Local $aPath_split = _PathSplit($sPath, $sDrive, $sDir, $sFilename, $sExt)

    Return $sDrive & $sDir & "\"
EndFunc; _FileGetDirPath

Func _GetFileName($sPath)
    Local $sDrive = "", $sDir = "", $sFilename = "", $sExt = ""

    Local $aPath_split = _PathSplit($sPath, $sDrive, $sDir, $sFilename, $sExt)

    Return $sFilename & $sExt
EndFunc; _GetFileName

 

If anyone else tries these scripts.  Start with zip in post one, then if you're having problems replace the contents of easyPlayer.au3 with my revision of script.  

The first GUI that appeared for me was a Green options dialog.  The main dialog doesn't load until you press the 'Okay' button.  The script relaunches it'self too at that stage (before pressing 'Okay') I had to Kill Process Tree.  After pressing 'Okay' at the Green dialog it doesn't happen anymore (script does not relaunch).

Why does it relaunch @nacerbaaziz?

Edited by Xandy

Share this post


Link to post
Share on other sites

Hello dear
Thank you for your nice post and for your modification of the file and to alerted me about the unintended mistake
My brother so far I have not finished working on the options page
It is Requiring a restart Because I will put some options for the screen readers and these options require restart
and about the  fileOptions.au3 file
I will amend the above publication and will add it to anyone who wants to benefit from it
With my best greetings and best wishesTHE

fileOptions.au3

Share this post


Link to post
Share on other sites

I am interested in writing the recorder.  I have a lot of work these weeks to come (day job) and I still have lots to learn about your script.  I have written a multi-track recorder already.  I will enjoy integrating our two scripts.

I'll start by saving a recording of stereo mix from computer output, then a microphone, then I'll see if I can output a file with both.

Edit: If that sounds like a reasonable plan.

Edited by Xandy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By ripdad
      This is a project that I have been working on for several months off and on.
      It's a simple "What You Hear" MP3 @ 320Kbps and WAV audio recorder.
      Features:
      - LoudMax, a Gain Controller and Look-Ahead Limiter
      - Auto Shut-Off after one minute of silence
      - Side-by-Side Simulated LED Meter
      - Running Time Counter
      It started off being a large project, but I eventually stripped it down to its
      bare essentials because I came to realize that it would be very difficult to
      deal with every sound card and every way a PC is set up for audio. It would
      have been a nightmare that I was not willing to go through.
      This project contains the most up-to-date BASS.dll v.2.4.15.0 - December 17, 2019.
      All BASS Dll's are 32bit. Those and the needed UDF's are included in the zip file.
      I will try to explain how it works in the next post.

      Download:
      BASS VST Recorder v1.1.zip
       
    • By nacerbaaziz
      question about _WinAPI_CreateWindowEx
      good morning
      welcome autoit team
      please i need your help
      i've searched a lot about how to use the _WinAPI_CreateWindowEx
      finally i found an example
      but i found some problem i hope you can help me
      firstly, i want to set the controls focussable with the keyboard input
      i already used the ws_tabStop but it did not work with me.
      secondly, i want to set some access keys linked with the window
      such as control+o enable the open button and control+f4 exit the app
      note: i need a local access keys and not a global hotkeys
      such as GUISetAccelerators
      finaly, before i will put the code here i must clarify a few things.
      1. you will ask me why you don't use the GUICreate function
      here i'll tell you that it as dialog and It is a little heavy in motion with screen readers.
      the screen readers for blind has some function that work with dialogs and others work with full windows style
      2. you will ask me why you didn't search the net for that?
      i will tell you that all examples that i found in the internet with pdfs and Picture books.
      i found some examples in microsoft but it with cpp.
      ok here is the code
      i hope you can help me to do what i want
      thank you in advance
       
      ; Small AutoIt Application that uses Windows API ; Written by Yuraj #NoTrayIcon #include <_RegisterClassEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <FontConstants.au3> AutoItSetOption("MustDeclareVars", 1) ; Window definitions Const $WinWidth = 370 Const $WinHeight = 350 Const $WinXPos = (@DesktopWidth / 2) - ($WinWidth / 2) Const $WinYPos = (@DesktopHeight / 2) - ($WinHeight / 2) Const $WinTitle = "Win32 Application - Text reader" Const $WinClass = "mainapp" Const $WinIcon = _WinAPI_LoadIcon(_WinAPI_GetModuleHandle("shell32.dll"), 13) ; Windows handles Global $hwnd, $edit1, $btn1, $btn2 ; Fonts Global $fnt1 ; Register class, Create the window Local $retVal = __WinAPI_RegisterClassEx($WinClass, "WindowCallback", $WinIcon, 0, _WinAPI_GetSysColor($COLOR_BTNFACE), BitOR($CS_DEFAULTSTYLE, $CS_DROPSHADOW)) ; If $retVal == 0 Then ; If registerclass fails MsgBox(16, "Error", "Error while registering window class!") Exit EndIf ; Create windows/controls $hwnd = _WinAPI_CreateWindowEx($WS_EX_STATICEDGE, $WinClass, $WinTitle, BitOR($WS_OVERLAPPED,$WS_SYSMENU, $WS_MINIMIZEBOX, $WS_GROUP, $WS_DLGFRAME), $WinXPos, $WinYPos, $WinWidth, $WinHeight, 0) $btn1 = _WinAPI_CreateWindowEx(0, "button", "Open file ...", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 25, 270, 100, 30,$hwnd) $btn2 = _WinAPI_CreateWindowEx(0, "Button", "Exit", BitOR($WS_VISIBLE, $WS_CHILD, $WS_TABSTOP, $WS_CLIPCHILDREN), 235, 270, 100, 30, $hwnd) $edit1 = _WinAPI_CreateWindowEx(0, "edit", "text", BitOR($WS_VISIBLE, $WS_CHILD, $WS_VSCROLL, $ES_AUTOVSCROLL, $es_readOnly, $WS_TABSTOP), 5, 5, $WinWidth - 15, $WinHeight - 100, $hwnd) ; Set controls identifiers _WinAPI_SetWindowLong($btn1,$GWL_ID,150) _WinAPI_SetWindowLong($btn2,$GWL_ID,160) ; Set (controls) fonts $fnt1 = _CreateFont("MS Sans Serif", 15) _WinAPI_SetFont($btn1, $fnt1) _WinAPI_SetFont($btn2, $fnt1) _WinAPI_SetFont($edit1, $fnt1) ; Set focus to edit _WinAPI_SetFocus($edit1) ; Show window _WinAPI_ShowWindow($hwnd) _WinAPI_UpdateWindow($hwnd) ; Main loop that keep application opened While 1 Sleep(100) WEnd ;=================================================================; ; WINDOW CALLBACK ... ;=================================================================; Func WindowCallback($_hwnd, $iMsg, $wParam, $lParam) Local $iNC, $iID Switch $iMsg ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_CLOSE ; Show message on closing If MsgBox(48 + 4, $WinTitle, "Do you want really exit?", 0, $hwnd) <> 6 Then Return 0 ; Call destructor and then exit main thread FinalizeApp() Exit ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Case $WM_COMMAND $iNC = _WinAPI_HiWord($wParam) $iID = _WinAPI_LoWord($lParam) Switch $iNC Case $BN_CLICKED ; When is control clicked Switch _WinAPI_GetDlgCtrlID($iID) Case _WinAPI_GetDlgCtrlID($btn1) BtnOpenFileClick() Case _WinAPI_GetDlgCtrlID($btn2) BtnExitClick() EndSwitch EndSwitch ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EndSwitch Return _WinAPI_DefWindowProc($_hwnd, $iMsg, $wParam, $lParam) EndFunc ;==>WindowCallback Func FinalizeApp() _WinAPI_DeleteObject($fnt1) _WinAPI_DestroyWindow($hwnd) __WinAPI_UnregisterClass($WinClass) EndFunc ;==>FinalizeApp Func _CreateFont($fontName, $height = 16, $style = $FW_NORMAL, $italic = False, $underline = False, $strikeout = False) Local $hFont = _WinAPI_CreateFont($height, 0, 0, 0, $style, $italic, $underline, $strikeout, $DEFAULT_CHARSET, _ $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $DEFAULT_QUALITY, $DEFAULT_PITCH, $fontName) Return $hFont EndFunc ;==>_CreateFont ;=================================================================; ; WINDOW EVENTS ;=================================================================; Func BtnOpenFileClick() Local $ret = _WinAPI_GetOpenFileName("", "Text files (*.txt)|All files (*.*)", ".", "", "", 1, 0, 0, $hwnd) If ($ret[0] > 0) Then Local $path = $ret[1] & "\" & $ret[2] Local $file = _WinAPI_CreateFile($path, 2, 2) Local $buf = DllStructCreate("byte[" & _WinAPI_GetFileSizeEx($file) & "]") Local $i = 0 _WinAPI_ReadFile($file, DllStructGetPtr($buf), _WinAPI_GetFileSizeEx($file), $i) ; Close file handle _WinAPI_CloseHandle($file) _WinAPI_SetWindowText($edit1, BinaryToString(DllStructGetData($buf, 1))) EndIf EndFunc ;==>BtnOpenFileClick Func BtnExitClick() FinalizeApp() Exit EndFunc ;==>BtnExitClick  
      _RegisterClassEx.au3
    • By ripdad
      This is an example script of how to load and use a VST using BASS in AutoIt.
      It is NOT immediately Plug and Play. You will need to download 2 VST's to run it.
      They are free for personal use.
      All information is in the header of the script.

      Download:
      BASS VST HOST v0.4.zip
       
    • By CYCho
      This file includes all the source codes and a compiled .exe version of zPlayer, which is a stand-alone, simple, intuitive and easy-to-use, yet fully functional audio player.  I made this to suit my purpose and you can tweak it to your taste as the source code is only about 1000 lines which are very much readable.  This player has the following functions:
      - Play back all formats of audio files which can be palyed back by the Windows Media Player in your computer
      - Graphical player similar to embedded Windows Media Player
      - Forward, backward, pause, repeat, shuffle funtions
      - Increase/decrease/mute sound volume
      - Change folders and create playlist for all audio files in that folder and its subfolders, and support for manually-made playlists
      - Save play-back environment when terminating and resume that environment when restarting
      - With one click, you can see DuckDuckGo search results for the file being played back
      - With a double-click, you can play back an item in the playlist
      - Search strings in the playlist
      - Option to see long file names including folder names
      - Resize the playlist window, and restore it to its default position
      - Very small footprint: very low CPU and memory usage, with only about 1MB when compiled
      - You can even hide all the windows and manipulate the player with hotkeys only
      Note: zPlayer is the name I used when I introduced the early version of this palyer in my blog back in early 2009 and, therefore, has nothing to do with the mobile media player of the same name which started marketing in 2015.
×
×
  • Create New...