Generate/play sounds without files

BlitzMax Forums/BlitzMax Beginners Area/Generate/play sounds without files

Czar Flavius(Posted 2010) [#1]
Is there a way to generate or play a 'sound' without loading an external .wav .ogg etc file? It doesn't have to resemble anything, a variety of beeps of differing frequencies or notes will do nicely! Thanks.


Zeke(Posted 2010) [#2]
Extern "win32"
	Function Beep:Int(freq:Int , duration:Int)
EndExtern

Beep(500,100)



Czar Flavius(Posted 2010) [#3]
Thanks! :D

What does Beep return?


Czar Flavius(Posted 2010) [#4]
I tried it but I don't hear anything.


skidracer(Posted 2010) [#5]
See the CreateAudioSample example in the docs for generating a basic audio wave.


Charrua(Posted 2010) [#6]
hi, the duration parameter is in milisecs, so try something greater than 100, the first (frequency) is in hertz, try 1000 for starting, below 200 probably you ear nothing, avobe 10,000 the same

do a loop with increments of 100 herts wiht a duration of 0.1 seconds: 100 milisecs

i try it in blitz3d and work perfectly in my laptop (same api call, i guess sould be the same from bMax)

Juan


Charrua(Posted 2010) [#7]
afaik, that command control the internal pc speaker (that is controlled by the timer 2 of the old 8253 chip), not the sound card, in some older motherboards it should be disconnected and so, it never sounds, in other it should be connected to an input of the sound card to ear it, check the mixer to see if the speaker is conected to it, not muted etc
hope that help

Juan


Czar Flavius(Posted 2010) [#8]
Thanks for the CreateAudioSample suggestion.

Hm, it appears I may not have an internal pc speaker (or it isn't plugged in)..