Code archives/Miscellaneous/PC Beep!
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
The important bit here really is the line: ----Print Chr(7)---- If you look up ASCII tables, you will see that 7 is infact, 'Bell'... God knows what you might use it for. As for the timer, basically it lays out a rythem in this sort of fashion NOTE: 1 2 3 4 5 6 7 8 9 10 TIME: 100---200---300---400---500---600---700---800 Each note (value in the array) is given a value from the time scale. ---------------------------------------------------------------- The timer works on all platforms, but the beep doesn't work in MaxIDE, I have only seen it work in Windows CMD. It would be easy enough to change the "beep" function to something else, perhaps something to play a sound with your speakers. You may also find that you cannot have fast rythems, because one beep must end for another to start ---------------------------------------------------------------- Feel free to use it, it is not particularly advanced anyway... however if you are rich, or own an aeroplane with the game then feel free to contact me and share the wealth! (only joking) Happy Beeping! | |||||
Framework BRL.StandardIO SuperStrict '/------------------------\' '|''''''BEEPER TYPE'''''''|' '\------------------------/' Type TBeep 'Beep Timer Type Field Timer:Int[254] Field time:Int=0 Field notes:Byte=0 Method SetTune(tune:Byte) ''Sets tune, you can add tunes to this yourself with ease. ''argument=tune number Select tune Case 0 Timer[0]=1 Timer[1]=300 Timer[2]=500 Timer[3]=600 Timer[4]=900 Timer[5]=1500 Timer[6]=1800 Notes=6 ''SET NOTES TO THE END NOTE NUMBER (6 in this case) Default Timer[0]=0 EndSelect EndMethod Method Beep() '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''Beep!'''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''''''' Print Chr(7) EndMethod Method tick:Byte() ''Call this function to continue one step through the beep sequence ''Returns 1 if the sequence is not fineshed, returns 0 if it is. time:+1 If time>=Timer[0] Beep() If Not Timer[1]=0 For Local i:Byte=1 To notes Timer[i-1]=Timer[i] 'Print timer[i] <-- Some debug thing for debuging etc Timer[i]=0 Next Else Timer[0]=0 Return 0 EndIf EndIf Return 1 EndMethod Method TimerReset() ''Reset the tune. time=0 EndMethod EndType '/------------------------\' '|'''''EXAMPLE PROGRAM''''|' '\------------------------/' Global Beeper:TBeep=New TBeep Beeper.SetTune(0) Repeat Delay 1 Until Beeper.tick()=0 |
Comments
| ||
its not working for me.... :( it says "expecting end-of-file" then again im a noob so..... oh wait it isnt bb :( lol yep im a noob |
Code Archives Forum