Sign in to follow this  
Followers 0
matthieuvb

SoundMaker

4 posts in this topic

a simple and easy program to make simple sounds. ;)

(it's in dutch)

here is the script:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\SoundMaker.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=SoundMaker
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Language=1043
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****


#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#NoTrayIcon

Opt("GUIOnEventMode", 1)

Global $Step[9999][4], $BK, $NX, $PA, $Slider, $Slider2, $Combo
Global $NumberMenu, $GUI, $PlayMenu, $NowRunningProject, $ExitCode
Global $szDrive, $szDir, $szFName, $szExt, $SMPPPLUSMenu, $SMPPMenu

Global $OD1, $OD2, $OD3, $OD4

_SoundMaker_Startup()

Func _SoundMaker_Startup()
$GUI = GUICreate("SoundMaker - Project1", 250, 250)
GUISetOnEvent($GUI_EVENT_CLOSE, "_SoundMaker_Exit")
$Step[0][0] = 0
$Slider = GUICtrlCreateSlider(10, 60, 230, 25)
GUICtrlSetLimit(-1, 20)
$Slider2 = GUICtrlCreateSlider(10, 100, 230, 25)
GUICtrlSetLimit(-1, 20)
$BK = GUICtrlCreateButton("Vorige", 10, 20, 60, 23)
GUICtrlSetState($BK, $GUI_DISABLE)
GUICtrlSetOnEvent(-1, "_SoundMaker_BackButton")
GUICtrlSetTip($BK, "Vorige")
$SP = GUICtrlCreateButton("Pagina opslaan", 75, 20, 90, 23)
GUICtrlSetOnEvent($SP, "_SoundMaker_SavePage")
GUICtrlSetTip($SP, "Pagina opslaan")
$NX = GUICtrlCreateButton("Volgende", 170, 20, 60, 23)
GUICtrlSetOnEvent($NX, "_SoundMaker_NextButton")
GUICtrlSetTip($NX, "Volgende")

$Label1 = GUICtrlCreateLabel("0 Hz", 10, 150, 80, 24)
GUICtrlSetTip(-1, "Frequentie in Herz")
$Label2 = GUICtrlCreateLabel("0 ms", 150, 150, 80, 24)
GUICtrlSetTip(-1, "Tijd in miliseconden")

$PA = GUICtrlCreateButton("Afspelen", 10, 190, 80, 24)
GUICtrlSetOnEvent($PA, "_SoundMaker_PlaySound")
GUICtrlSetTip($PA, "Project afspelen")

$Combo = GUICtrlCreateCombo("5", 150, 190, 80, 24)
GUICtrlSetData(-1, "10|15|20|25|30")
GUICtrlSetTip($Combo, "Pagina's")
GUICtrlSetOnEvent($Combo, "_SoundMaker_Combo")

$FileMenu = GUICtrlCreateMenu("Project")
GUICtrlCreateMenuItem("Nieuw", $FileMenu)
GUICtrlSetOnEvent(-1, "_SoundMaker_NewProject")
GUICtrlCreateMenuItem("Opslaan", $FileMenu)
GUICtrlSetOnEvent(-1, "_SoundMaker_SaveSound")
GUICtrlCreateMenuItem("", $FileMenu)
GUICtrlCreateMenuItem("Importeren", $FileMenu)
GUICtrlSetOnEvent(-1, "_SoundMaker_SelectImportSound")
GUICtrlCreateMenuItem("", $FileMenu)
$PlayMenu = GUICtrlCreateMenuItem("Afspelen", $FileMenu)
GUICtrlSetOnEvent(-1, "_SoundMaker_PlaySound")
$Play2Menu = GUICtrlCreateMenu("Afspelen met", $FileMenu)

GUICtrlCreateMenuItem("", $FileMenu)
GUICtrlCreateMenuItem("Onderdelen", $FileMenu)
GUICtrlSetOnEvent(-1, "_SoundMaker_ViewOD")

$SMPPMenu = GUICtrlCreateMenuItem("SMPP", $Play2Menu)
GUICtrlSetOnEvent(-1, "_SoundMaker_PlaySoundWithSMPP")
GUICtrlCreateMenuItem("SM (standaard)", $Play2Menu)
GUICtrlSetOnEvent(-1, "_SoundMaker_PlaySound")
$SMPPPLUSMenu = GUICtrlCreateMenuItem("SMPP+", $Play2Menu)
GUICtrlSetOnEvent(-1, "_SoundMaker_PlaySoundWithSMPPPLUS")
GUICtrlCreateMenuItem("WMP", $Play2Menu)
GUICtrlSetState(-1, $GUI_DISABLE)

$NumberMenu = GUICtrlCreateMenu("Pagina " & 0 & "/5")
GUICtrlSetState($NumberMenu, $GUI_DISABLE)

GUISetState()

If FileExists(@ScriptDir & "\SoundMaker_ProjectPlayer x86.exe") Or FileExists(@ScriptDir & "\SMPP x86.exe") Or FileExists(@ScriptDir & "\SMPP.exe") Or FileExists(@ScriptDir & "\SoundMaker_ProjectPlayer.exe") Or FileExists(@ScriptDir & "\SoundMakerProjectPlayer.exe") Or FileExists(@ScriptDir & "\SoundMaker ProjectPlayer.exe") Then
    $OD1 = "Geïnstalleerd"
Else
    GUICtrlSetState($SMPPMenu, $GUI_DISABLE)
    $OD1 = "Niet geïnstalleerd"
EndIf

If FileExists(@ScriptDir & "\SMPPplus.exe") Or FileExists(@ScriptDir & "\SMPPplus x86.exe") Or FileExists(@ScriptDir & "\SMPPplus_x86.exe") Then
    $OD2 = "Geïnstalleerd"
Else
    GUICtrlSetState($SMPPPLUSMenu, $GUI_DISABLE)
    $OD2 = "Niet geïnstalleerd"
EndIf

If $CmdLine[0] > 0 Then
    If $CmdLine[1] = "SoundMaker" Then
    Else
    _SoundMaker_ImportSound($CmdLine[1])
    EndIf
EndIf

    While 1
        Sleep(50)
        GUICtrlSetData($Label1, ((GUICtrlRead($Slider) * 2000) / 20) & " Hz")
        Sleep(50)
        GUICtrlSetData($Label2, ((GUICtrlRead($Slider2) * 2000) / 20) & " ms")
    WEnd
EndFunc

Func _SoundMaker_Exit()
    Exit
EndFunc


Func _SoundMaker_NextButton()
    If $Step[0][0] + 1 > GUICtrlRead($Combo) Then
    Msgbox(48, "SoundMaker", "Aantal pagina's overtreden.", -1, $GUI)
    Else
    $Step[0][0] = $Step[0][0] + 1
    $Step[0][1] = $Step[0][1] + 1
    $NS = $Step[0][0]
    GUICtrlSetState($BK, $GUI_ENABLE)
    GUICtrlSetData($NumberMenu, "Pagina " & $Step[0][0] & "/" & GUICtrlRead($Combo))

    GUICtrlSetData($Slider, $Step[$NS][1])
    GUICtrlSetData($Slider2, $Step[$NS][2])
    EndIf
EndFunc

Func _SoundMaker_BackButton()
    $Step[0][0] = $Step[0][0] - 1
    $Step[0][1] = $Step[0][1] - 1
    $NS = $Step[0][0]
    If $Step[0][0] = 0 Then
    GUICtrlSetState($BK, $GUI_DISABLE)
    EndIf
    GUICtrlSetData($NumberMenu, "Pagina " & $Step[0][0] & "/" & GUICtrlRead($Combo))
    GUICtrlSetData($Slider, $Step[$NS][1])
    GUICtrlSetData($Slider2, $Step[$NS][2])
EndFunc

Func _SoundMaker_PlaySound()
    GUICtrlSetState($PlayMenu, $GUI_DISABLE)
    GUICtrlSetState($PA, $GUI_DISABLE)
    Sleep(300)
    For $i = 0 To GUICtrlRead($Combo) Step 1
        If $Step[$i][1] = 0 Then
            If $Step[$i][2] = 0 Then
            Else
            Sleep(($Step[$i][2] * 2000) / 20)
            EndIf
        Else
        Beep(($Step[$i][1] * 2000) / 20, ($Step[$i][2] * 2000) / 20)
        EndIf
    Next
    GUICtrlSetState($PlayMenu, $GUI_ENABLE)
    GUICtrlSetState($PA, $GUI_ENABLE)
EndFunc

Func _SoundMaker_Combo()
    GUICtrlSetData($NumberMenu, "Pagina " & $Step[0][0] & "/" & GUICtrlRead($Combo))
EndFunc

Func _SoundMaker_SavePage()
    $NS = $Step[0][0]
    $Step[$NS][1] = GUICtrlRead($Slider)
    $Step[$NS][2] = GUICtrlRead($Slider2)
EndFunc

Func _SoundMaker_SaveSound()
    If FileExists($NowRunningProject) Then
    $WriteFile = $NowRunningProject
    Else
    $WriteFile = FileSaveDialog("SoundMaker", @MyDocumentsDir, "SoundMaker files(*.smp)", 2, "Project1", $GUI)
    EndIf
    $Path = _PathSplit($WriteFile, $szDrive, $szDir, $szFName, $szExt)
    If $WriteFile = "" Then
    Else
    Select
        Case $szExt = ".smp"
        Case $szExt = ""
        $WriteFile = $WriteFile & ".smp"
        Case Else
        $WriteFile = $szDrive & $szDir & $szFName & ".smp"
    EndSelect
        FileDelete($WriteFile)
        Sleep(200)
        FileWrite($WriteFile, "")
    For $i = 0 To GUICtrlRead($Combo) Step 1
        IniWrite($WriteFile, "MySMProject", $Step[$i][1], $Step[$i][2])
    Next
    If FileExists($WriteFile) Then
    $NowRunningProject = $WriteFile
    WinSetTitle($GUI, "", "SoundMaker - " & $szFName)
    Else
    Msgbox(16, "SoundMaker", "Er is een fout opgetreden bij het Opslaan!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(@Error, 8), -1, $GUI)
    Exit
EndIf
EndIf
EndFunc

Func _SoundMaker_SelectImportSound()
    _SoundMaker_ImportSound(FileOpenDialog("SoundMaker", @MyDocumentsDir, "SoundMaker files(*.smp)", 3, "", $GUI))
EndFunc

Func _SoundMaker_ImportSound($OpenProject)

    If $OpenProject = "" Then
    Else
    Global $Step[9999][4]
    If Not FileExists($OpenProject) Then
    Msgbox(16, "SoundMaker", "Het Geopende project bestaat niet!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(8, 8), -1, $GUI)
    Exit
    EndIf
    $StepRead = IniReadSection($OpenProject, "MySMProject")
    If @Error Then
    Msgbox(16, "SoundMaker", "Er is een fout opgetreden bij het importeren!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(@Error, 8), -1, $GUI)
    Exit
    EndIf

    For $i = 1 To ($StepRead[0][0]) Step 1
        $A = ($i - 1)
        $Step[$A][2] = $StepRead[$i][1]
        $Step[$A][1] = $StepRead[$i][0]
    Next

    GUICtrlSetData($Combo, "|" & $StepRead[0][0], $StepRead[0][0])
    GUICtrlSetData($NumberMenu, "Pagina " & 0 & "/" & $StepRead[0][0])
    $Step[0][0] = 0
    $NS = $Step[0][0]
    If $StepRead[0][0] = 0 Then
        MsgBox(16, "SoundMaker", "Er zijn geen pagina's gevonden in het geladen project!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(7, 8), -1, $GUI)
        Exit
    Else

    _PathSplit($OpenProject, $szDrive, $szDir, $szFName, $szExt)
    $NowRunningProject = $OpenProject
    WinSetTitle($GUI, "", "SoundMaker - " & $szFName)

    GUICtrlSetData($Slider, $Step[$NS][1])
    GUICtrlSetData($Slider2, $Step[$NS][2])
    EndIf
    EndIf
EndFunc

Func _SoundMaker_PlaySoundWithSMPP()
    If FileExists($NowRunningProject) Then

    Select
        Case FileExists(@ScriptDir & "\SoundMaker_ProjectPlayer x86.exe")
        RunWait(@ScriptDir & "\SoundMaker_ProjectPlayer x86.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SoundMaker ProjectPlayer.exe")
        RunWait(@ScriptDir & "\SoundMaker ProjectPlayer.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SoundMaker_ProjectPlayer.exe")
        RunWait(@ScriptDir & "\SoundMaker_ProjectPlayer.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SoundMakerProjectPlayer.exe")
        RunWait(@ScriptDir & "\SoundMakerProjectPlayer.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SMPP.exe")
        RunWait(@ScriptDir & "\SMPP.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SMPP x86.exe")
        RunWait(@ScriptDir & "\SMPP x86.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SMPP_x86.exe")
        RunWait(@ScriptDir & "\SMPP_x86.exe " & $NowRunningProject)

        Case Else
        Msgbox(16, "SoundMaker", "SoundMaker kan het programma SMPP.exe niet vinden." & @CRLF & "Controleer de onderdelen." & @CRLF & "error code: " & Hex(11, 8), -1, $GUI)

    EndSelect

    Else
    Msgbox(16, "SoundMaker", "De SMPP mode werkt alleen bij opgeslagen projecten." & @CRLF & "Sla het project op om het in deze mode af te spelen." & @CRLF & "error code: " & Hex(13, 8), -1, $GUI)
    EndIf
EndFunc

Func _SoundMaker_PlaySoundWithSMPPPLUS()
        If FileExists($NowRunningProject) Then

    Select
        Case FileExists(@ScriptDir & "\SMPPplus.exe")
        RunWait(@ScriptDir & "\SMPPplus.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SMPPplus x86.exe")
        RunWait(@ScriptDir & "\SMPPplus x86.exe " & $NowRunningProject)

        Case FileExists(@ScriptDir & "\SMPPplus_x86.exe")
        RunWait(@ScriptDir & "\SMPPplus_x86.exe " & $NowRunningProject)

        Case Else
        Msgbox(16, "SoundMaker", "SoundMaker kan het programma SMPPplus.exe niet vinden." & @CRLF & "Controleer de onderdelen." & @CRLF & "error code: " & Hex(31, 8), -1, $GUI)

    EndSelect

    Else
    Msgbox(16, "SoundMaker", "De SMPP+ mode werkt alleen bij opgeslagen projecten." & @CRLF & "Sla het project op om het in deze mode af te spelen." & @CRLF & "error code: " & Hex(32, 8), -1, $GUI)
    EndIf

EndFunc

Func _SoundMaker_NewProject()
    RunWait(@ScriptFullPath)
    Sleep(200)
EndFunc

Func _SoundMaker_ViewOD()
    $ExitCode = False
    Msgbox(64, "SoundMaker", "Geïnstalleerde onderdelen:" & @CRLF & @CRLF & "SMPP: " & $OD1 & @CRLF & "SM: Ingebouwd" & @CRLF & "SMPP+: " & $OD2 & @CRLF & "WMP:  Niet geïnstalleerd", -1, $GUI)
EndFunc

Func _SoundMaker_SetExitCode()
    $ExitCode = True
EndFunc

And an extra player:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\SMPP.exe
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Description=SMPP
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Language=1043
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <Misc.au3>
#NoTrayIcon


If _Singleton("SoundMakerProjectPlayerMP", 1) = 0 Then
    Exit
EndIf

Global $Step[9999][4], $Pages


If $CmdLine[0] > 0 Then
    _SoundMaker_ImportSound($CmdLine[1])
    _SoundMaker_PlayLoadedProject()
    Else
    _SoundMaker_ImportSound(FileOpenDialog("SMPP", @MyDocumentsDir, "SoundMaker files(*.smp)", 3, ""))
    _SoundMaker_PlayLoadedProject()
EndIf

Func _SoundMaker_ImportSound($OpenProject)

    If $OpenProject = "" Then
    Else
    Global $Step[9999][4]
    If Not FileExists($OpenProject) Then
    Msgbox(16, "SoundMaker", "Het Geopende project bestaat niet!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(8, 8))
    Exit
    EndIf
    $StepRead = IniReadSection($OpenProject, "MySMProject")
    If @Error Then
    Msgbox(16, "SoundMaker", "Er is een fout opgetreden bij het importeren!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(@Error, 8))
    Exit
    EndIf
    $Pages = $StepRead[0][0]
    For $i = 1 To $Pages Step 1
        $A = ($i - 1)
        $Step[$A][2] = $StepRead[$i][1]
        $Step[$A][1] = $StepRead[$i][0]
    Next

    $Step[0][0] = 0
    $NS = $Step[0][0]
    If $StepRead[0][0] = 0 Then
        MsgBox(16, "SoundMaker", "Er zijn geen pagina's gevonden in het geladen project!" & @CRLF & "Het programma wordt nu gesloten." & @CRLF & "error code: " & Hex(7, 8))
        Exit
    EndIf
    EndIf
EndFunc

Func _SoundMaker_PlayLoadedProject()
    For $i = 0 To ($Pages) Step 1
        If $Step[$i][1] = 0 Then
            If $Step[$i][2] = 0 Then
            Else
            Sleep(($Step[$i][2] * 2000) / 20)
            EndIf
        Else
        Beep(($Step[$i][1] * 2000) / 20, ($Step[$i][2] * 2000) / 20)
        EndIf
    Next
EndFunc

try it out!


[font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]

Share this post


Link to post
Share on other sites



Please could you translate your script ? Posted Image


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Please could you translate your script ? Posted Image

sorry, but I do not really have time. (and no sense ;) ) Edited by Matthieuautoitscripter

[font=Helvetica, Arial, sans-serif][background=rgb(252, 252, 250)][/background][/font]

Share this post


Link to post
Share on other sites

how to use it? i couldn't !

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  
Followers 0