Page 1 of 1

xplatform Why just a beep()

Posted: Sun Aug 11, 2019 8:24 am
by collectordave
Edited from Original:

After suggestions about create sound and a little more thought I asked myself 'Why Just A Beep?'

Many different sounds can be created with SoundEasy.pbi so reprogrammed to this:

Code: Select all

InitSound()

IncludeFile "SoundEasy.pbi"

Enumeration Warnings
  #Beep
EndEnumeration 


Procedure SoundWarning(Warning.i)
  
  Define CurrentSound.i
  
  InitSound()
  
  Select Warning
      
    Case #Beep

      CurrentSound = CreateSound(#PB_Any, 1000, 0.5) 

  EndSelect

  PlaySound(CurrentSound)

  
  While SoundStatus(CurrentSound) <> #PB_Sound_Stopped : Wend

  FreeSound(CurrentSound)

EndProcedure


SoundWarning(#Beep)

Delay(1000)
Imagination is the only limit here.

If anyone creates a sound with SoundEasy post here with the title for your sound and I can add to the code above.

We could end up with a whole library of sounds far exceeding the lowly beep.

collectordave

Re: xplatform Beep No API

Posted: Sun Aug 11, 2019 8:39 am
by collectordave
Just thought of something need to use freesound()

Modyfied code below:-

Code: Select all

Procedure Beep(Duration.i)
  
 ;Duration maximum 500 milliseconds 
 
InitSound()

CurrentSound = LoadSound(#PB_Any, "Beep.wav")

PlaySound(CurrentSound)

Delay(Duration)

FreeSound(CurrentSound)

EndProcedure

Beep(500)

Delay (300)

Beep(100)
CD

Re: xplatform Beep No API

Posted: Sun Aug 11, 2019 12:00 pm
by blueb
Looks interesting Dave.

If you're looking for something that allows you to add
sounds to your programs without any external sound files
you might check out BasicallyPure's CreateSound() command in:
SoundEasy.pbi (appears to be cross platform)

viewtopic.php?p=405772#p405772

Re: xplatform Beep No API

Posted: Sun Aug 11, 2019 2:27 pm
by collectordave
Rewritten with no external file.

Duration now in seconds.

Code: Select all

IncludeFile "SoundEasy.pbi"

Procedure Beep(Duration.f)
  
  Define CurrentSound.i
  
  InitSound()
  
  CurrentSound = CreateSound(#PB_Any, 1000, Duration) 

  PlaySound(CurrentSound)

  While SoundStatus(CurrentSound) <> #PB_Sound_Stopped : Wend

  FreeSound(CurrentSound)

EndProcedure

Beep(0.5)

Delay (1000)

Beep(1.5)
You now only need this and the soundeasy.pbi

Re: xplatform Why just a beep()

Posted: Mon Aug 12, 2019 6:32 am
by collectordave
Original Post edited with new ideas.

If the code in the first post could be run in a thread it would also not block application running.

So:-

SoundWarning(#Beep) ;As a thread
Messagerequester()

Would be Ok.

CD