General Discussions

Working with music in Blitz Basic – MTecknology

MTecknology

Member

Posts: 13
From:
Registered: 08-18-2003
I have all needed files, and clearly dont know enough about this language.
I want it so that when the user presses a number(above the letters) the song will change. If anybody feels compelled to completely rewrite the code, I would like it to be in a function, hopefully this makes it easier for you .
My Code 'Snippet'(I don't want to put to much on here.-->
;;;
backgroundmusic1 = PlayMusic("1. Around The World.mp3")
;;;
Const D = 32, Key1 = 2, Key2 = 3, Key3 = 4, Key4 = 5, Key5 = 6, Key6 = 7, Key7 = 8
Const Key8 = 9, Key9 = 20, Key0 = 11
;;;
Global sound ;sound file being played
sound = 1 ;1-9,0

Global Key ;key been pressed for music
;;;
If KeyHit(Key1)
Key = 1
Else
Key = 101
EndIf
If KeyHit(Key2)
Key = 2
Else
Key = 101
EndIf
If KeyHit(Key3)
Key = 3
Else
Key = 101
EndIf
If KeyHit(Key4)
Key = 4
Else
Key = 101
EndIf
If KeyHit(Key5)
Key = 5
Else
Key = 101
EndIf
If KeyHit(Key6)
Key = 6
Else
Key = 101
EndIf
If KeyHit(Key7)
Key = 7
Else
Key = 101
EndIf
If KeyHit(Key8)
Key = 8
Else
Key = 101
EndIf
If KeyHit(Key9)
Key = 9
Else
Key = 101
EndIf
If KeyHit(Key0)
Key = 0
Else
Key = 101
EndIf
If Key <> 101
;should use an array
;stop channel
If sound = 1 Then
StopChannel(backgroundmusic1)
EndIf
If sound = 2 Then
StopChannel(backgroundmusic2)
EndIf
If sound = 3 Then
StopChannel(backgroundmusic3)
EndIf
If sound = 4 Then
StopChannel(backgroundmusic4)
EndIf
If sound = 5 Then
StopChannel(backgroundmusic5)
EndIf
If sound = 6 Then
StopChannel(backgroundmusic6)
EndIf
If sound = 7 Then
StopChannel(backgroundmusic7)
EndIf
If sound = 8 Then
StopChannel(backgroundmusic8)
EndIf
If sound = 9 Then
StopChannel(backgroundmusic9)
EndIf
If sound = 0 Then
StopChannel(backgroundmusic0)
EndIf
;start sound
If Key = 1 Then
backgroundmusic1 = PlayMusic("1. Around The World")
sound = 1
EndIf
If Key = 2 Then
backgroundmusic2 = PlayMusic("2. Parallel Universe")
sound = 2
EndIf
If Key = 3 Then
backgroundmusic3 = PlayMusic("3. Scar Tissue")
sound = 3
EndIf
If Key = 4 Then
backgroundmusic4 = PlayMusic("4. Otherside")
sound = 4
EndIf
If Key = 5 Then
backgroundmusic5 = PlayMusic("6. Californication")
sound = 5
EndIf
If Key = 6 Then
backgroundmusic6 = PlayMusic("7. Easily")
sound = 6
EndIf
If Key = 7 Then
backgroundmusic7 = PlayMusic("9-0. Emit Remmus")
sound = 7
EndIf
If Key = 8 Then
backgroundmusic8 = PlayMusic("9-1. I Like Dirt")
sound = 8
EndIf
If Key = 9 Then
backgroundmusic9 = PlayMusic("9-3. Savior")
sound = 9
EndIf
If Key = 0 Then
backgroundmusic0 = PlayMusic("9-4. Purple Stain")
sound = 0
EndIf
EndIf

------------------
You will find me where the light don't shine, where the people are silently friendly, where we are the most intelligent, and where all can live down under, until our trip to heaven.

baykar

Member

Posts: 11
From: aleppo,syria
Registered: 08-27-2003
Hiiiiiiiiiiiii mteck i hadn't understood what you are really looking for but here is a code for you


AppTitle "music"

Global m1,m2,m3,m4
Global playing

Repeat

If KeyHit(2) Gosub music1
If KeyHit(3) Gosub music2
If KeyHit(4) Gosub music3
If KeyHit(5) Gosub music4
If KeyHit(31) Then Gosub stop1
If KeyHit(25) Then Gosub resume
If KeyHit(1) Then End

Forever


.music1
StopChannel playing
m1=PlayMusic("1.wav")
playing=m1
Return

.music2
StopChannel playing
m2=PlayMusic("2.wav")
playing=m2
Return

.music3
StopChannel playing
m3=PlayMusic("3.wav")
playing=m3
Return

.music4
StopChannel playing
m4=PlayMusic("4.wav")
playing=m4
Return

.stop1
PauseChannel playing
Return

.resume
ResumeChannel playing
Return

is this what you are looking for?????
i hope this helps

----------
*******
baykar
*******
----------