none
How do I add sound in the backround of my program? RRS feed

  • Question

  • How do I add sound from my computer into my program in the background.  I would like to make a program where you click on the screen and it plays music.  
    Friday, November 29, 2013 2:03 AM

Answers

  • simple sample.  If you click "Play" button, doremi sound is played.

    GraphicsWindow.Show()
    Controls.ButtonClicked=playnotes
    Controls.AddButton("Play",50,100)

    Sound.Play("C:\Users\Public\Music\Sample Music\Kalimba.mp3") '  background music

    Sub playnotes
      doremi="O5 C3 D8 E3 C8 E4 C4 E2 O5 D3 E8 F8 F8 E8 D8 F1 O5 E3 F8 G3 E8 G4 E4 G2 O5 F3 G8 A8 A8 G8 F8 A1"
      doremi=doremi+" O5 G3 C8 D8 E8 F8 G8 A1 O5 A3 D8 E8 F#8 G8 A8 B1 O5 B3 E8 F#8 G#8 A8 B8 > C1.5 O5 B8 B-8  A4 F4 B4 G4 > C1"
      Sound.PlayMusic(doremi)
    EndSub

    *  Sound.PlayMusic(notes) cannot play background.  if you want to play music background,

    use Sound.Play("somemusic.mp3")

     
    Friday, November 29, 2013 4:28 AM
    Answerer

All replies

  • How do I add sound from my computer into my program in the background.  I would like to make a program where you click on the screen and it plays music.  I all ready know Sound.PlayMusic("oa 8e 4d").

    Friday, November 29, 2013 2:07 AM
  • simple sample.  If you click "Play" button, doremi sound is played.

    GraphicsWindow.Show()
    Controls.ButtonClicked=playnotes
    Controls.AddButton("Play",50,100)

    Sound.Play("C:\Users\Public\Music\Sample Music\Kalimba.mp3") '  background music

    Sub playnotes
      doremi="O5 C3 D8 E3 C8 E4 C4 E2 O5 D3 E8 F8 F8 E8 D8 F1 O5 E3 F8 G3 E8 G4 E4 G2 O5 F3 G8 A8 A8 G8 F8 A1"
      doremi=doremi+" O5 G3 C8 D8 E8 F8 G8 A1 O5 A3 D8 E8 F#8 G8 A8 B1 O5 B3 E8 F#8 G#8 A8 B8 > C1.5 O5 B8 B-8  A4 F4 B4 G4 > C1"
      Sound.PlayMusic(doremi)
    EndSub

    *  Sound.PlayMusic(notes) cannot play background.  if you want to play music background,

    use Sound.Play("somemusic.mp3")

     
    Friday, November 29, 2013 4:28 AM
    Answerer
  • Hi Yeagerashtonm

    Following on NaochanON's sample, a further option is if you want to play sounds as well as the background sound track, and be able to stop the sound track you can put the Sound.Play(soundTrackPath) in the main thread and Sound.PlayMusic(notes) in different threads to the sound track.

    PJN903

    Saturday, November 30, 2013 2:29 PM
    Moderator