# PureBasic Forum

 It is currently Fri Oct 30, 2020 11:20 am

 All times are UTC + 1 hour

 Page 2 of 2 [ 23 posts ] Go to page Previous  1, 2
 Print view Previous topic | Next topic
Author Message
 Post subject: Posted: Tue Apr 26, 2005 3:43 pm

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)

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

 Post subject: Posted: Tue Apr 26, 2005 3:51 pm
 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

 Post subject: Posted: Fri May 06, 2005 6:23 am
 Enthusiast

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

Top

 Post subject: Posted: Fri May 06, 2005 6:25 am

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

Top

 Post subject: Posted: Tue May 10, 2005 7:31 am
 Enthusiast

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

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

;- Window Constants
;
Enumeration
#Window_Main
EndEnumeration

;
Enumeration
EndEnumeration

Enumeration
EndEnumeration

;
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()
Else
End
EndIf

If CreateStatusBar(#StatusBar_Main,WindowID())
StatusBarText(0, 0,"Status - Sucking your CPU Cycles!")
Else
End
EndIf

Else
End
EndIf

Else
End
EndIf
EndProcedure

If OpenFile(0,file)
CurrentData\NoteCount=NoteCount
Dim Notes.Note(NoteCount)
For i=0 To NoteCount
Next i
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
EndProcedure

Procedure CheckEvents()
Event=WindowEvent()
Select Event
file.s=OpenFileRequester("Load a Tune to play","*.ism","Tune File *.ism|*.ism",0)
If file<>""
CurrentData\file=file
CurrentData\tempo=#TempoDefault
CurrentData\frequency=#FrequencyDefault
CurrentData\sourcenote=0
IsPlaying=#True
StatusBarText(0, 0,"Status - Playing "+GetFilePart(CurrentData\file))
EndIf
EndIf
CurrentData\file=""
CurrentData\tempo=0
CurrentData\frequency=0
CurrentData\NoteCount=0
CurrentData\sourcenote=0
IsPlaying=#False
If CurrentData\file<>""
IsPlaying=#True
StatusBarText(0, 0,"Status - Playing "+GetFilePart(CurrentData\file))
EndIf
IsPlaying=#False
CurrentData\sourcenote=0
StatusBarText(0, 0,"Status - Stopped Playing "+GetFilePart(CurrentData\file))
IsPlaying=#False
StatusBarText(0, 0,"Status - Paused Playing "+GetFilePart(CurrentData\file))
End
EndSelect
Case #TrackBar_Position
Destination=CurrentData\NoteCount
Source=Percentage*Destination
CurrentData\sourcenote=Source
Debug "Source = "+StrF(Source)
Case #TrackBar_Temo
Debug "Tempo = "+Str(CurrentData\tempo)
Case #TrackBar_Freq
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
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
Global tempo.w
Dim Note.Note(Length-1)
For tmp=0 To Length-1
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

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()
Repeat
e=WindowEvent()
While e
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!

_________________
~Dreglor

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

Top

 Post subject: Posted: Tue May 10, 2005 8:14 am
 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

 Post subject: Posted: Tue May 10, 2005 2:41 pm
 Enthusiast

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

_________________
~Dreglor

Top

 Post subject: Posted: Fri Jun 17, 2005 2:31 am
 Enthusiast

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

_________________

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 2 of 2 [ 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 28 guests

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

Search for:
 Jump to:  Select a forum ------------------ PureBasic    Coding Questions    Game Programming    3D Programming    Assembly Programming    The PureBasic Editor    The PureBasic Form Designer    General Discussion    Feature Requests and Wishlists    Tricks 'n' Tips Bug Reports    Bugs - Windows    Bugs - Linux    Bugs - Mac OSX    Bugs - IDE    Bugs - Documentation OS Specific    AmigaOS    Linux    Windows    Mac OSX Miscellaneous    Announcement    Off Topic Showcase    Applications - Feedback and Discussion    PureFORM & JaPBe    TailBite