It is currently Tue Nov 24, 2020 4:54 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: Tue Apr 26, 2005 3:43 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 12, 2005 3:35 am
Posts: 803
Location: Germany(Hessen)
Code:
Declare Synth1(Note.l,laenge.l)
Declare Synth2(Note.l,laenge.l)
Declare Smash(laenge.l)



If OpenWindow (1,0,0,400,10,#pb_window_screencentered|#pb_window_systemmenu,"Queekno volume 1")


Smash (20)
Delay (40)
Smash (20)
Delay (20)
Smash (20)
Delay (40)
Smash (20)
Delay (20)
Smash (20)
Delay (20)
Repeat
event.l=WindowEvent()
If zaehler>33
 Restore Musik
 zaehler=0
 Delay(20)
Smash (20)
Delay (40)
Smash (20)
Delay (20)
Smash (20)
Delay (40)
Smash (20)
Delay (20)
Smash (20)
Delay (20)
EndIf
zaehler+1
takt.l+1
If takt.l>1:takt.l=0:EndIf
Read note.l
If takt.l=0:Synth1(Note.l,10):Else: Synth2(Note.l,10):EndIf
Smash (20)

Until event.l=#pb_event_closewindow

EndIf



End



Procedure Synth1(Note.l,laenge.l)
For x=1 To laenge.l
Beep_(Note.l,10)
Beep_(Note.l*4,15)
Beep_(Note.l*2,15)
Next x
EndProcedure

Procedure Synth2(Note.l,laenge.l)
For x=1 To laenge.l
Beep_(Note.l,10)
Beep_(Note.l*3,15)
Beep_(Note.l*5,15)
Next x
EndProcedure

Procedure Smash(laenge.l)
For x=1 To laenge.l
Beep_(800+Random(1000),2)
Beep_(1000,1)
Beep_(200+Random(1000),2)
Next x
EndProcedure

DataSection
Musik:
Data.l 1114,1114,834,834,884,884,992,992,1114,1114,834,834,884,884,992,992
Data.l 1114,834,2228,834,1669,1768,1114,834,2228,834,1669,1768,1114,834,2228,834,1669,1768
EndDataSection

_________________
German blog about IT and programming
German PB forums


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Apr 26, 2005 3:51 pm 
Offline
Enthusiast
Enthusiast

Joined: Sun Aug 29, 2004 2:25 pm
Posts: 149
Location: United Kingdom
Lol, thats pretty cleaver, nice one

I have a really loud internal speaker :S


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 06, 2005 6:23 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Apr 27, 2005 9:41 pm
Posts: 150
Location: Finland
this one was gooood :D


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri May 06, 2005 6:25 am 
Offline
Addict
Addict
User avatar

Joined: Mon Sep 20, 2004 3:52 pm
Posts: 1648
rofl this is hilarious


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 10, 2005 7:31 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Aug 02, 2003 11:22 pm
Posts: 759
Location: OR, USA
I made a Player!

Code:
;tune player
;by dreglor
;5-09-05

;- Window Constants
;
Enumeration
  #Window_Main
EndEnumeration

;- MenuBar Constants
;
Enumeration
  #MenuBar_0
EndEnumeration

Enumeration
  #MENU_Open
  #MENU_Close
  #MENU_Play
  #MENU_Stop
  #MENU_Pause
  #MENU_Quit
EndEnumeration

;- Gadget Constants
;
Enumeration
  #TrackBar_Position
  #Text_info1
  #TrackBar_Temo
  #Text_2
  #TrackBar_Freq
  #Text_5
  #Button_Play
  #Button_Stop
  #Button_Pause
EndEnumeration

;- StatusBar Constants
;
Enumeration
  #StatusBar_Main
EndEnumeration

;-Program Constants
;
#isLooped=#True
#TempoDefault=100
#FrequencyDefault=100

;-Structures
;
Structure Note
  freq.w
  duration.w
EndStructure

Structure current
  file.s
  sourcenote.l
  NoteCount.l
  tempo.f
  frequency.f
EndStructure

;-Globals
;
Global CurrentData.current
Global IsPlaying.b

;-Procedures
;
Procedure Open_Window_Main()
  If OpenWindow(#Window_Main,221,0,320,240,#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_TitleBar|#PB_Window_ScreenCentered,"Tune Player!")
    If CreateMenu(#MenuBar_0,WindowID())
      MenuTitle("File")
      MenuItem(#MENU_Open,"Open "+Chr(9)+" Ctrl+O")
      MenuItem(#MENU_Close,"Close "+Chr(9)+" Ctrl+C")
      MenuBar()
      MenuItem(#MENU_Play,"Play "+Chr(9)+" Ctrl+P")
      MenuItem(#MENU_Stop,"Stop "+Chr(9)+" Ctrl+S")
      MenuItem(#MENU_Pause,"Pause "+Chr(9)+" Ctrl+F")
      MenuBar()
      MenuItem(#MENU_Quit,"Quit "+Chr(9)+" Ctrl+Q")
    Else
      End
    EndIf
   
    If CreateStatusBar(#StatusBar_Main,WindowID())
      StatusBarText(0, 0,"Status - Sucking your CPU Cycles!")
    Else
      End
    EndIf
   
    If CreateGadgetList(WindowID())
      TrackBarGadget(#TrackBar_Position,0,180,320,20,0,100)
      TextGadget(#Text_info1,0,160,320,20,"Current Place: 0")
      TrackBarGadget(#TrackBar_Temo,0,120,320,20,1,200)
      TextGadget(#Text_2,0,100,320,20,"Current Tempo: 100")
      TrackBarGadget(#TrackBar_Freq,0,60,320,20,1,200)
      TextGadget(#Text_5,0,40,320,20,"Current Frequency: 100")
      ButtonGadget(#Button_Play,10,10,50,20,"Play")
      ButtonGadget(#Button_Stop,130,10,50,20,"Stop")
      ButtonGadget(#Button_Pause,250,10,50,20,"Pause")
    Else
      End
    EndIf
   
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_O,#MENU_Open)
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_C,#MENU_Close)
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_P,#MENU_Play)
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_S,#MENU_Stop)
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_F,#MENU_Pause)
    AddKeyboardShortcut(#Window_Main,#PB_Shortcut_Control|#PB_Shortcut_Q,#MENU_Quit)
    SetGadgetState(#TrackBar_Temo,#TempoDefault)
    SetGadgetState(#TrackBar_Position,0)
    SetGadgetState(#TrackBar_Freq,#FrequencyDefault)
  Else
    End
  EndIf
EndProcedure

Procedure LoadTune(file.s)
  If OpenFile(0,file)
    NoteCount=ReadLong()
    CurrentData\NoteCount=NoteCount
    Dim Notes.Note(NoteCount)
    For i=0 To NoteCount
      Notes(i)\freq=ReadWord()
      Notes(i)\duration=ReadWord()
    Next i
    ProcedureReturn 1
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Procedure CheckEvents()
  Event=WindowEvent()
  Select Event
    Case #PB_Event_Menu
      MenuEvent=EventMenuID()
      Select MenuEvent
        Case #MENU_Open
          Debug "Menu Open"
          file.s=OpenFileRequester("Load a Tune to play","*.ism","Tune File *.ism|*.ism",0)
          If file<>""
            If LoadTune(file)
            CurrentData\file=file
            CurrentData\tempo=#TempoDefault
            CurrentData\frequency=#FrequencyDefault
            CurrentData\sourcenote=0
            SetGadgetState(#TrackBar_Temo,#TempoDefault)
            SetGadgetState(#TrackBar_Position,0)
            SetGadgetState(#TrackBar_Freq,#FrequencyDefault)
            IsPlaying=#True
            StatusBarText(0, 0,"Status - Playing "+GetFilePart(CurrentData\file))
            EndIf
          EndIf
        Case #MENU_Close
          Debug "Menu Close"
          CurrentData\file=""
          CurrentData\tempo=0
          CurrentData\frequency=0
          CurrentData\NoteCount=0
          CurrentData\sourcenote=0
          IsPlaying=#False
        Case #MENU_Play
          Debug "Menu Play"
          If CurrentData\file<>""
            IsPlaying=#True
            StatusBarText(0, 0,"Status - Playing "+GetFilePart(CurrentData\file))
          EndIf
        Case #MENU_Stop
          Debug "Menu Stop"
          IsPlaying=#False
          CurrentData\sourcenote=0
          StatusBarText(0, 0,"Status - Stopped Playing "+GetFilePart(CurrentData\file))
        Case #MENU_Pause
          Debug "Menu Pause"
          IsPlaying=#False
          StatusBarText(0, 0,"Status - Paused Playing "+GetFilePart(CurrentData\file))
        Case #MENU_Quit
          Debug "Menu Quit"
          End
      EndSelect
    Case #PB_Event_Gadget
      GadgetEvent=EventGadgetID()
      Select GadgetEvent
        Case #TrackBar_Position
            Percentage.f=(GetGadgetState(#TrackBar_Position))/100
            Destination=CurrentData\NoteCount
            Source=Percentage*Destination
            CurrentData\sourcenote=Source
            Debug "Source = "+StrF(Source)
          Case #TrackBar_Temo
            CurrentData\tempo=GetGadgetState(#TrackBar_Temo)
            SetGadgetText(#Text_2,"Current Tempo: "+StrF(CurrentData\tempo/100))
            Debug "Tempo = "+Str(CurrentData\tempo)
        Case #TrackBar_Freq
          CurrentData\frequency=GetGadgetState(#TrackBar_Freq)
          SetGadgetText(#Text_5,"Current Frequency: "+StrF(CurrentData\frequency/100))
          Debug "Frequency = "+Str(CurrentData\frequency)
        Case #Button_Play
          If CurrentData\file<>""
            IsPlaying=#True
            StatusBarText(0, 0,"Status - Playing "+GetFilePart(CurrentData\file))
          EndIf
        Case #Button_Stop
          IsPlaying=#False
          CurrentData\sourcenote=0
          StatusBarText(0, 0,"Status - Stopped Playing "+GetFilePart(CurrentData\file))
        Case #Button_Pause
          IsPlaying=#False
          StatusBarText(0, 0,"Status - Paused Playing "+GetFilePart(CurrentData\file))
      EndSelect
    Case #PB_Event_CloseWindow
        End
    ;Case #PB_Event_Repaint
    ;Case #PB_Event_SizeWindow
    ;Case #PB_Event_MoveWindow
  EndSelect
EndProcedure

Open_Window_Main()
Repeat
  Delay(1)
  CheckEvents()
  If IsPlaying=#True
    f=Notes(CurrentData\sourcenote)\freq
    d=Notes(CurrentData\sourcenote)\duration
    fa=f*(CurrentData\frequency/100)
    da=d*(CurrentData\tempo/100)
    Beep_(fa,da)
    Debug fa
    Debug da
    If CurrentData\sourcenote=CurrentData\NoteCount
      If #isLooped=#True
        CurrentData\sourcenote=0
      Else
        IsPlaying=#False
        CurrentData\sourcenote=0
      EndIf
    EndIf
    CurrentData\sourcenote+1
    Percentage.f=(CurrentData\sourcenote/CurrentData\NoteCount)*100
    SetGadgetText(#Text_info1,"Current Place: "+Str(CurrentData\sourcenote))
    SetGadgetState(#TrackBar_Position,Percentage)
  EndIf
ForEver


here is a generators for the 2 songs that can make from (easily)

Code:
OpenFile(0,"C:\Guns & Roses.ism")
WriteLong(49)
WriteWord(284) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(284) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(319) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(319) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(568) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(379) : WriteWord(200)
WriteWord(758) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(716) : WriteWord(200)
WriteWord(426) : WriteWord(200)
WriteWord(284) : WriteWord(200)
CloseFile(0)



Code:
; 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()
  OpenFile(0,"C:\Sloppy Rave.ism")
  WriteLong(64)
  For tmp=0 To Length-1
    a=Note(tmp)\Note-1 : b=Note(tmp)\base-1
    ;Beep_(notefreq(a,b),15000/tempo)
    WriteWord(notefreq(a,b))
    WriteWord(15000/tempo)
  Next
  CloseFile(0)
EndProcedure

PlayIt()
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
 
 


if you want to write your own ISM files (for the player) use this format

Code:
[Note Count as Long][Note Frequency as Word][Note Length as Word]

A note being a single Beep_ command

besides a few bugs (like the tempo reversed bug) the player works

Im waiting for some one to convert the mario theme song
maybe from midi? or somthing :?:

enjoy! :D

_________________
~Dreglor


Last edited by Dreglor on Tue May 10, 2005 2:42 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 10, 2005 8:14 am 
Offline
Enthusiast
Enthusiast

Joined: Wed Apr 27, 2005 9:41 pm
Posts: 150
Location: Finland
nice prog :)

1. crashes if not file selected...
2. if file selected and then closed play will start but and place starts to count upwars... possibly crashing later...

i think you should fix them to pop up message box if not ism file open...


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue May 10, 2005 2:41 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Aug 02, 2003 11:22 pm
Posts: 759
Location: OR, USA
fixed!

_________________
~Dreglor


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Jun 17, 2005 2:31 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 02, 2005 3:55 am
Posts: 501
Location: U.S.A.
All very much awesome :!:

_________________
Intrigued - Registered PureBasic, lifetime updates user


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 31 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye