none
Small Basic 1.0 Problem with Sound.play RRS feed

  • Question

  • I am trying to teach my Son to program, and came across the sound control, he wants to write something which will play a piece of music by various instruments according to user input...

    1st I downloaded a piece of piano music to "c:\mp3s\" called it "Piano_alb_esp6.mp3"

    Then I tried to get Small Basic to play the music using this code

     

    'Sound.PlayBellRing()
    
    'Sound.PlayChime()
    
    'TextWindow.WriteLine("playing some music")
    
    'Sound.PlayMusic("O4 C8 C8 G8 G8 A8 A8 G4 F8 F8 E8 E8 D8 D8 C4 O5 C8 C8 G8 G8 A8 A8 G4 F8 F8 E8 E8 D8 D8 C4 O8 C8 C8 G8 G8 A8 A8 G4 F8 F8 E8 E8 D8 D8 C4")
    
    musicloop:
    
    'GraphicsWindow.BackgroundColor = "green"
    
    Sound.stop ("c:\mp3s\Piano_alb_esp6.mp3")
    
    Sound.Playandwait ("c:\mp3s\Piano_alb_esp6.mp3")
    
    
    
    'Sound.Stop("c:\windows\media\windows xp battery low.wav")
    
    'Sound.Playandwait("c:\windows\media\windows xp battery low.wav")
    
     GraphicsWindow.Show()  'something to close when done playing
    
    
    
      Done = "False"
    
      While(Done = "False")
    
        Program.Delay(1)   
    
      EndWhile

     

    Most of that is irrelevant, but shows what I have tried to do to get it to work.. 

     

    Other sounds controls work (e.g. sound.playchime, or sound.playmusic).

     

    Any ideas anyone?

    Tuesday, October 25, 2011 1:29 PM

Answers

  • My PC (XP) also does not work sound.Play("******") .

    But Process.start command woks well.

    If you have Data Extension , try this.

    Process.start("c:\mp3s\Piano_alb_esp6.mp3")

     

    Wednesday, October 26, 2011 3:38 AM
    Answerer

All replies

  • For me all the sounds work using similar code to you (if they have a valid sound file), including Sound.Play with an mp3. 

    Which specific sound command isn't working, or is it something to do with the other code?

    Don't run sound commands inside an event subroutine.

     

    Tuesday, October 25, 2011 6:27 PM
    Moderator
  • ok, specifically it seems as if neither sound.play nor sound.playandwait work.


    the mp3 works from windows explorer, but not in here....

     

    the path is correct.

     

    I'm wondering if the problem could be due to the _ in the file name...

    Tuesday, October 25, 2011 6:41 PM
  • I replaced your file, with one of my mp3s, originally ripped from a CD - my file path has no _, but it does have white space in it and plays OK.

    Suggest you try some more mp3s maybe from other sources and maybe rename them something simple.  Do other file types, e.g. wav etc work with Sound.Play?

    Tuesday, October 25, 2011 6:51 PM
    Moderator
  • i tried it with some of the default xp .wavs also with no joy....
    Tuesday, October 25, 2011 7:48 PM
  • Checking the SB source shows the only difference between the Play and other sound commands is that the Play uses .Net mediaplayer - I assume you have .Net 3.5 SP1 installed.

    It could be an XP issue, many apps require SP3 with XP.

    Perhaps try the Data extension that has SoundPlus, some of which has the same functionality as the native SmallBasic version, but may be coded differently.

    Otherwise, sorry.

    Tuesday, October 25, 2011 8:11 PM
    Moderator
  • OK, that must be it, works fine on Windows 7. Shall check the .net stuff on my Son's XP machine.


    Thanks loads.

     

    Argon0

    Tuesday, October 25, 2011 8:29 PM
  • Whoops that was me with my work account....
    Tuesday, October 25, 2011 8:43 PM
  • Looks like I've got .Net 3.5 with sp1 installed, and XP SP3...
    Tuesday, October 25, 2011 8:57 PM
  • My PC (XP) also does not work sound.Play("******") .

    But Process.start command woks well.

    If you have Data Extension , try this.

    Process.start("c:\mp3s\Piano_alb_esp6.mp3")

     

    Wednesday, October 26, 2011 3:38 AM
    Answerer