Speaker-Tecno

Share your advanced PureBasic knowledge/code with the community.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Speaker-Tecno

Post by Hroudtwolf »

Code updated For 5.20+

EVERYBODY, CLAP YOUR HANDS !!! :lol:


Code: Select all

#Grad2Rad=0.017453
OpenConsole()                                  
ConsoleTitle ("Tecno-Mucke")
repeat
For a=1 To 150 Step 10
Beep_(Int(Sin(a*#Grad2Rad)*1000), 10)
Beep_(Int(Sin(a*#Grad2Rad)*500), 5)
Beep_(Int(Cos(a*#Grad2Rad)*1000), 10)
Next
Delay(40)
For x=1 To 20
Beep_(100+Random (1000),3) 
Beep_(100+Random (1000),3)
Next x 
Delay(40)
For a=1 To 400 Step 10
Beep_(Int(Sin(a*#Grad2Rad)*1000), 10)
Beep_(Int(Sin(a*#Grad2Rad)*500), 5)
Beep_(Int(Cos(a*#Grad2Rad)*1000), 10)
Next
Delay(40)
For x=1 To 20
Beep_(100+Random (1500),3) 
Beep_(100+Random (1000),3)
Next x 
Delay(40)
For a=1 To 150 Step 10
Beep_(Int(Sin(a*#Grad2Rad)*2000), 10)
Beep_(Int(Sin(a*#Grad2Rad)*500), 5)
Beep_(Int(Cos(a*#Grad2Rad)*1000), 10)
Next
Delay(20)
For x=1 To 20
Beep_(100+Random (1000),3) 
Beep_(100+Random (1000),3)
Next x 
Delay(20)
For x=1 To 20
Beep_(100+Random (1500),3) 
Beep_(100+Random (1000),3)
Next x 
Until Inkey()<>""
CloseConsole()
Last edited by Hroudtwolf on Fri Apr 01, 2005 3:12 pm, edited 1 time in total.
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post by Tommeh »

Lol, My PC is dying! :)
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Yeah ,there must die more PCs.... :lol:

Code: Select all

Declare synth1()
Declare synth2()
Declare synth3()
Declare synth4()
OpenConsole()                                  
ConsoleTitle ("Tecno-Mucke")

Repeat
Read note

Select note
Case 1
synth1()
Case 2
synth2()
Case 3
synth3()
Case 4
synth4()

EndSelect

x=x+1
If x>23:x=0:Restore mucke::EndIf 
Delay (30)
Until Inkey()<>""
CloseConsole()



Procedure synth1()
For a=1 To 500 Step 10
Beep_(Int(Sin(a*0.017453)*1000), 5)
Beep_(Int(Cos(a*0.017453)*3000), 5)
Next
EndProcedure
Procedure synth3()
For a=1 To 500 Step 10
Beep_(Int(Sin(a*0.017453)*5000), 2)
Beep_(Int(Cos(a*0.017453)*2000), 5)
Next
EndProcedure
Procedure synth2()
For a=1 To 800 Step 10
Beep_(Int(Sin(a*0.017453)*Random(1000)), 1)
Beep_(Int(Cos(a*0.017453)*Random(5000)), 1)
Next
EndProcedure
Procedure synth4()
For a=1 To 800 Step 10
Beep_(Int(Sin(a*0.017453)*3000), 2)
Beep_(Int(Sin(a*0.017453)*1500), 2)
Next
EndProcedure








DataSection 
Mucke:
Data.l 1,2,1,3,1,2,1,3,1,2,1,3,1,1,4,1,4,1,4,1,2,1,3,1,4
EndDataSection
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

horrible!
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

:lol:
Annoying, but kinda funny.
First time I ran it, it gave me a flash back from the olden days hehehe
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
jack
Addict
Addict
Posts: 1336
Joined: Fri Apr 25, 2003 11:10 pm

Post by jack »

kind of reminds me of Moon Cresta :)
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Post by kenmo »

Hows this?

Code: Select all

; Sloppily Coded Rave by kenmo
; Tune written by "Toby"!

Structure Note
   base.b
   note.b
EndStructure

Global length.w : Read length.w : Global tempo.w : Read tempo.w : Dim Note.Note(length-1)
For tmp=0 To length-1
   Read note(tmp)\base : Read note(tmp)\note
Next tmp
Global a.b : Global b.b

Dim notefreq.w(11,9) : For tmp=0 To 11 : For tmp2=0 To 9 : Read notefreq(tmp,tmp2) : Next tmp2 : Next tmp
OpenWindow(0,0,0,300,40,#PB_Window_ScreenCentered|#PB_Window_SystemMenu,"Tempo: "+Str(tempo)+" bpm")
CreateGadgetList(WindowID())
TrackBarGadget(0,10,10,280,20,30,200) : SetGadgetState(0,tempo)

Procedure PlayIt()
   tmp=0
   Repeat
      a=note(tmp)\note-1 : b=note(tmp)\base-1
      Beep_(notefreq(a,b),15000/tempo)
      tmp+1 : If tmp=length : tmp=0 : EndIf
   ForEver
EndProcedure

   thread=CreateThread(@playit(),0)
   If thread
   Repeat
      e=WindowEvent()
      While e
         If e=#PB_EventCloseWindow : KillThread(thread) : End
         ElseIf e=#PB_EventGadget And EventGadgetID()=0
            tempo=GetGadgetState(0) : SetWindowTitle(0,"Tempo: "+Str(tempo)+" bpm")
         EndIf
         e=WindowEvent() : Delay(2)
      Wend
      Delay(2)
   ForEver
   Else : End : EndIf
   
DataSection
   ; Song Length, Tempo
   Data.w 64,100
   ; Base/Note
   Data.b 5,1
   Data.b 5,8
   Data.b 6,1
   Data.b 5,1
   Data.b 5,8
   Data.b 6,1
   Data.b 5,1
   Data.b 5,8
   Data.b 5,1
   Data.b 5,8
   Data.b 6,4
   Data.b 5,1
   Data.b 5,8
   Data.b 6,4
   Data.b 5,1
   Data.b 5,8
   Data.b 5,4
   Data.b 5,9
   Data.b 6,4
   Data.b 5,4
   Data.b 5,9
   Data.b 6,4
   Data.b 5,4
   Data.b 5,9
   Data.b 5,6
   Data.b 6,1
   Data.b 6,6
   Data.b 5,6
   Data.b 6,1
   Data.b 6,6
   Data.b 5,6
   Data.b 6,1
   Data.b 5,1
   Data.b 5,8
   Data.b 6,8
   Data.b 5,1
   Data.b 5,8
   Data.b 6,8
   Data.b 5,1
   Data.b 5,8
   Data.b 5,1
   Data.b 5,8
   Data.b 6,6
   Data.b 5,1
   Data.b 5,8
   Data.b 6,6
   Data.b 5,1
   Data.b 5,8
   Data.b 5,4
   Data.b 5,11
   Data.b 6,9
   Data.b 5,4
   Data.b 5,11
   Data.b 6,9
   Data.b 5,4
   Data.b 5,11
   Data.b 5,6
   Data.b 6,1
   Data.b 6,6
   Data.b 5,6
   Data.b 6,1
   Data.b 6,6
   Data.b 5,6
   Data.b 6,1
   
   ; Note Frequencies
   Data.w 16,32,65,130,261,523,1046,2093,4186,8372
   Data.w 17,34,69,138,277,554,1108,2217,4434,8869
   Data.w 18,36,73,146,293,587,1174,2344,4698,9397
   Data.w 19,38,77,155,311,622,1244,2489,4978,9956
   Data.w 20,41,82,164,329,659,1318,2637,5274,10548
   Data.w 21,43,87,174,349,698,1396,2793,5587,11175
   Data.w 23,46,92,184,369,739,1479,2959,5919,11839
   Data.w 24,48,97,195,391,783,1567,3135,6270,12541
   Data.w 25,51,103,207,415,830,1661,3322,6644,13289
   Data.w 27,55,110,220,440,880,1760,3520,7040,14080
   Data.w 29,58,116,233,466,932,1964,3729,7458,14917
   Data.w 30,61,123,246,493,987,1975,3951,7902,15804
EndDataSection
Last edited by kenmo on Fri Apr 15, 2005 12:30 am, edited 1 time in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

kenmo wrote:Hows this?
First tune posted here to meet the defintion of music! Like it! :D
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
GeoTrail
Addict
Addict
Posts: 2794
Joined: Fri Feb 13, 2004 12:45 am
Location: Bergen, Norway
Contact:

Post by GeoTrail »

Pretty cool, I kinda like it :)
I Stepped On A Cornflake!!! Now I'm A Cereal Killer!
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

@kenmo:

Indeed ... nice piece of melody :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post by Tommeh »

Ok i can't take credit for this, ages ago in my DarkBASIC years somebody posted a melody tune for the beginning of Guns & Roses, so i changed it to be and here it is:

Code: Select all

tempo=180
Beep_(284,tempo)
Beep_(568,tempo)
Beep_(426,tempo)
Beep_(379,tempo)
Beep_(758,tempo)
Beep_(426,tempo)
Beep_(716,tempo)
Beep_(426,tempo)

Beep_(284,tempo)
Beep_(568,tempo)
Beep_(426,tempo)
Beep_(379,tempo)
Beep_(758,tempo)
Beep_(426,tempo)
Beep_(716,tempo)
Beep_(426,tempo)

Beep_(319,tempo)
Beep_(568,tempo)
Beep_(426,tempo)
Beep_(379,tempo)
Beep_(758,tempo)
Beep_(426,tempo)
Beep_(716,tempo)
Beep_(426,tempo)

Beep_(319,tempo)
Beep_(568,tempo)
Beep_(426,tempo)
Beep_(379,tempo)
Beep_(758,tempo)
Beep_(426,tempo)
Beep_(716,tempo)
Beep_(426,tempo)

Beep_(379,tempo)
Beep_(568,tempo)
Beep_(426,tempo)
Last edited by Tommeh on Thu Apr 14, 2005 5:28 pm, edited 2 times in total.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

To my ears, you've got to change the second note of the first two rows:

Code: Select all

Beep_(568,tempo)
first is note is too sharp as well, but... ;)
Good programmers don't comment their code. It was hard to write, should be hard to read.
Tommeh
Enthusiast
Enthusiast
Posts: 149
Joined: Sun Aug 29, 2004 2:25 pm
Location: United Kingdom

Post by Tommeh »

As i said, i didnt make it but i've changed it.. if you think its for the better ;p
akee
Enthusiast
Enthusiast
Posts: 475
Joined: Wed Aug 18, 2004 9:52 am
Location: Penang, Malaysia

Post by akee »

Trigger back memories when we were in DOS using GWBASIC trying to write a game.
User avatar
Rescator
Addict
Addict
Posts: 1769
Joined: Sat Feb 19, 2005 5:05 pm
Location: Norway

Post by Rescator »

I couldn't help myself, turned this into a ringtone'ish function. heh.
minimum 1 loop, maximum 10 loops. has a finishing note when the loop is do ne.

Code: Select all

Procedure play(replay.l)
 tempo=180
 If replay>10 : replay=10 : EndIf
 If replay<1 : replay=1 : EndIf
 Repeat
  replay-1
  Beep_(284,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
  
  Beep_(284,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
  
  Beep_(319,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
  
  Beep_(319,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
  
  Beep_(379,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
  
  Beep_(379,tempo)
  Beep_(568,tempo)
  Beep_(426,tempo)
  Beep_(379,tempo)
  Beep_(758,tempo)
  Beep_(426,tempo)
  Beep_(716,tempo)
  Beep_(426,tempo)
 Until replay=0
 Beep_(284,tempo*2)
EndProcedure

play(2)
Post Reply