Sign in to follow this  
Followers 0
trancexx

DSBeep

5 posts in this topic

With the release of latest beta v3.3.7.22 code regarding Interfaces is completely finished. This allows native usage of many objects that required additional UDFs before (mainly AutoItObject). No more.

As example I will show how to use few DirectSound interfaces using nothing but built-in functions.

Script this was based on was posted (I have highlighted keywords). DirecSound's IDirectSound8 in combination with IDirectSoundBuffer interface imitates old beep sound.

Include script:

DSBeep.au3

An example could be (one of AZIJO's songs):

#include "DSBeep.au3"

Opt("MustDeclareVars", 1)
HotKeySet("{ESC}", "_Quit")

; Error monitoring (thru the life time of the script)
Global $oErrorObject = ObjEvent("AutoIt.Error", "_ErrFunc")
; Implemenation
Func _ErrFunc($oError)
    ConsoleWrite("COM Error, ScriptLine(" & $oError.scriptline & ") : Number 0x" & Hex($oError.number, 8) & " - " & $oError.windescription & @CRLF)
EndFunc   ;==>_ErrFunc

; Initialize DSBeep
_StartDSBeep()

; Play
_Beep(8, 4, 100, 0, 0.8, 0) ; set tempo and tone
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(1,5,100,100)
_Beep(8, 4, 100, 0, 1) ; new tempo
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100,100)
_Beep(12,4,100,100)
_Beep(8,4,100)
_Beep(7,4,100)
_Beep(8,4,100)
_Beep(9,4,100)
_Beep(8,4,100)
_Beep(6, 5, 100, 0, 0.8) ; new tempo
_Beep(3,5,100)
_Beep(12,4,100)
_Beep(8,4,100)
_Beep(6,4,100)
_Beep(5,4,100)
_Beep(4,4,200,300)
_Beep(1,5,100)
_Beep(12,4,100)
_Beep(11,4,100)
_Beep(9,4,100)
_Beep(1,5,100,100)
_Beep(6,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(8,4,100)
_Beep(1,5,100,100)
_Beep(4,5,100,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(3,5,100)
_Beep(3,4,100)
_Beep(7,4,100)
_Beep(10,4,100)
_Beep(1,5,100)
_Beep(4,5,100)
_Beep(3,5,100)
_Beep(1,5,100)
_Beep(3,5,250,250)
;===========================

_Beep(8, 4, 100, 0, 1.1) ; new tempo
_Beep(7, 4, 100)
_Beep(8, 4, 100)
_Beep(9, 4, 100)
_Beep(8, 4, 100, 100)
_Beep(1, 5, 100, 100)
_Beep(8, 4, 100)
_Beep(7, 4, 100)
_Beep(8, 4, 100)
_Beep(9, 4, 100)
_Beep(8, 4, 100, 100)
_Beep(12, 4, 100, 100)
_Beep(8, 4, 100)
_Beep(7, 4, 100)
_Beep(8, 4, 100)
_Beep(9, 4, 100)
_Beep(8, 4, 100)
_Beep(6, 5, 100)
_Beep(3, 5, 100)
_Beep(12, 4, 100)
_Beep(8, 4, 100)
_Beep(6, 4, 100)
_Beep(5, 4, 100)
_Beep(4, 4, 200, 300)
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(11, 4, 100)
_Beep(9, 4, 100)
_Beep(1, 5, 100, 100)
_Beep(6, 5, 100, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(8, 4, 100)
_Beep(1, 5, 100, 100)
_Beep(4, 5, 100, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(3, 5, 100)
;=============================
_Beep(8, 4, 100)
_Beep(12, 4, 100)
_Beep(3, 5, 100)
_Beep(8, 5, 100)
_Beep(6, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 300, 200)
_Beep(3, 5, 100, 0, 1.8) ; new tempo
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(11, 4, 100)
_Beep(4, 4, 100)
_Beep(8, 4, 100)
_Beep(11, 4, 100)
_Beep(4, 4, 100)
_Beep(8, 4, 100)
_Beep(11, 4, 100)
_Beep(12, 4, 100)
_Beep(1, 5, 150, 150)
_Beep(9, 4, 200, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(11, 4, 100)
_Beep(3, 4, 100)
_Beep(6, 4, 100)
_Beep(11, 4, 100)
_Beep(3, 4, 100)
_Beep(6, 4, 100)
_Beep(11, 4, 100)
_Beep(12, 4, 100)
_Beep(1, 5, 150, 150)
_Beep(8, 4, 200, 100)
_Beep(4, 5, 100, 0, 1.1) ; new tempo
_Beep(3, 5, 100)
_Beep(6, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(11, 4, 100)
_Beep(3, 5, 150, 150)
_Beep(11, 4, 300, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(11, 4, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(11, 4, 100)
_Beep(9, 4, 100)
_Beep(11, 4, 400, 100)
_Beep(3, 5, 100, 0, 1.8) ; new tempo
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(11, 4, 100)
_Beep(4, 4, 100)
_Beep(8, 4, 100)
_Beep(11, 4, 100)
_Beep(4, 4, 100)
_Beep(8, 4, 100)
_Beep(11, 4, 100)
_Beep(12, 4, 100)
_Beep(1, 5, 150, 150)
_Beep(9, 4, 200, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(11, 4, 100)
_Beep(3, 4, 100)
_Beep(6, 4, 100)
_Beep(11, 4, 100)
_Beep(3, 4, 100)
_Beep(6, 4, 100)
_Beep(11, 4, 100)
_Beep(12, 4, 100)
_Beep(1, 5, 150, 150)
_Beep(8, 4, 150, 150)
_Beep(4, 5, 100, 0, 1.2) ; new tempo
_Beep(3, 5, 100)
_Beep(2, 5, 100)
_Beep(1, 5, 100)
_Beep(12, 4, 100)
_Beep(1, 5, 100)
_Beep(3, 5, 100)
_Beep(6, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(4, 5, 100)
_Beep(11, 4, 100)
_Beep(4, 5, 100)
_Beep(8, 5, 100)
_Beep(11, 5, 100, 0, 0.8) ; new tempo
_Beep(10, 5, 100)
_Beep(9, 5, 100)
_Beep(8, 5, 100)
_Beep(6, 5, 100)
_Beep(4, 5, 100)
_Beep(3, 5, 100)
_Beep(1, 5, 100)
_Beep(11, 4, 100)
_Beep(9, 4, 100, 0, 0.5) ; new tempo
_Beep(8, 4, 100)
_Beep(6, 4, 100, 0, 0.2) ; new tempo
_Beep(4, 4, 200)

; Stop the engine
_StopDSBeep()
; Exit (redundant)
_Quit()

Func _Quit()
    Exit
EndFunc   ;==>_Quit

Have that code in the same folder as DSBeep.au3.

1 person likes this

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites



That rocks !

When will you stop to amaze us ! :D


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)

I was planning on waiting for the new release of AutoIt, since I have so many unfinished projects and fear being overwhelmed by the changes taking place. The first DSBeep was excellent since it called the current native beep function which allows you to set the pitch to any frequency. I am now slightly concerned that DSBeep will only play a limited range of frequencies (tempered notes).

Some things I didn't like about AZIJO's original design. $iPause is a bad idea, and would be better replaced by the start time of the note. (eg Note starts at 6000 ms and lasts for 2 seconds). I'm not sure what is meant by $iTone. I presume it means you can alter the wave form. I'm also unclear about how $iTempo relates to note duration, or why it is even needed. Until I have the latest version of AutoIt I can't test it, but I'm sure it will be good regardless. It's just that I would have made some different choices for this particular script.

Perhaps my concerns are needless, since all that I might need or use can be written as a UDF; and as you say, this is just an example. I don't yet know what treasures await me in the new release. I look forward to trying it when it arrives.

:D

Edit Number(I've forgotten)

Aghh I'm sure it will all turn out to be good. Sorry for nitpicking about AZILO's design.

Edited by czardas

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Apologies. All is well since this can be altered. :D

Local $iFrequency = 440 * 2 ^ (($iNote + $iToneLocal) / 12 + $iOctave + 1 / 6 - 4)

Thanks for all the great stuff you keep producing.

Edited by czardas

Share this post


Link to post
Share on other sites

@trancexx

Hi, I confess that I do not understand much the code, especially the function: ObjCreateInterface()

But I'll try to see the examples and maybe I'll end up understand better, anyway, very good script

Regards,

João Carlos.


http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

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

  • Similar Content

    • eukalyptus
      By eukalyptus
      DirectSound UDF
      play audio files, record microphone, apply effects or create your own sound - check out the examples
      Download: https://autoit.de/index.php/Attachment/69-DirectSound-7z/
      Or visit the original topic at the german forum - link in my signature