BASIC

Author Topic: Tiny Request: Playing a sampleloop (not musicloop)  (Read 4948 times)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3326
    • View Profile
    • Space Fractal
PLAYSOUND(sfx, pan#, volume#, loop#) where loop is TRUE or FALSE. This would not break combatible at all, since loop# should only been a option of course.

Yes I are aware of SOUNDPLAYING(), but its cannot been used fora  looped sound because this require very careful timing as well. And its would also chop sometimes anyway and then cutter when lopped.

For stopping the sound, simply add a STOPSOUND(sfx) command.

Also changing panning and volume on a played sound while playing a sample would been nice, but not required.

PS. Yes you can do looped music which is very nice, the only reason is I need two looped samples (one music, and one sfx).
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Dynamic Panning and Volume would make for a really nice gaming atmosphere :)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline r0ber7

  • Dr. Type
  • ****
  • Posts: 469
    • View Profile
Dynamic Panning and Volume would make for a really nice gaming atmosphere :)

+1  :good:

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4061
    • View Profile
    • Portfolio
It sure would be nice to have our sound system improved on a few ways.

Offline r0ber7

  • Dr. Type
  • ****
  • Posts: 469
    • View Profile
Being able to adjust volume and panning while playing a sound would make me do a little dance of happy.

Offline Gary

  • Dr. Type
  • ****
  • Posts: 313
    • View Profile
it would also remove the need to specify how many times to repeat the sample when loading it which I believe takes up 4 times the memory if you tell GLB to play the sample 4 times at the point of loading.

Is any of the above posts requests at all possible kitty?

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10651
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
I'll have a look. I wanted to either switch to SDL for windows anyway, or write my own mixer routines that would allow a lot of other messings. It's just a lot of additional work.

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2459
    • View Profile
I would like to see openal used across all platforms. It would allow messing about at a lot lower level. I realise windows would need an extra DLL but it's a small price to pay for a much better API  IMHO.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10651
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Can I link OpenAL statically?

Offline Albert

  • Dr. Type
  • ****
  • Posts: 257
    • View Profile
    • Blog
+1 for OpenAL

Offline aonyn

  • Mr. Polyvector
  • ***
  • Posts: 133
    • View Profile
Please, +1 for me also.

Thanks,
Dave
For by grace are ye saved through faith, and that not of yourselves: it is the gift of God: Not of works, lest any man should boast. -Ephesians 2:8-9

Offline bigsofty

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 2459
    • View Profile
Can I link OpenAL statically?

If its just Windows then:

Well I think, MINGW links to it statically( See http://www.nongnu.org/mingw-cross-env/#packages ), so it seems to be possible. I have not tried it, also a quick google brought up this post, http://permalink.gmane.org/gmane.comp.lib.openal/6355

Its a bit of a grey area though.

That being said, personally I don't mind making sure that the little the openal DLL is part of the final distro for my program.
Cheers,

Ian.

“It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration.”
(E. W. Dijkstra)

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3326
    • View Profile
    • Space Fractal
For the tiny request I originally asked, possible to loop samples as well dymanic control volume and panning. That would works in most games really we create in this language really (including that game I create). I have a little sirene sound I want to been looped (and can been stopped at any time), but might allready have music played in background.

Its would been great to let to mix it to 22khz to save cpu as well, which could been wonderfull for those lesser powered Android devices or general. Example I use 22khz mono sound samples, so I have no need to mix to a 44khz output at all. I would do reduced very much cpu time here.

PS. OpenAL would been a great bonus for much more advanced control and could been using with new commands rather than replace them (and might limit support of devices, hence own commands here). Also if you ask me as others say, I would also not mind to include a dll file too at all. That even its should only been required for Windows 98 and XP. With OpenAL you should also been possible to support more than just PCM wav files.

« Last Edit: 2012-Jan-09 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Nathan

  • Mr. Polyvector
  • ***
  • Posts: 116
    • View Profile
For looping sounds (only), would this help at all?

http://www.glbasic.com/forum/index.php?topic=3917.0

As I also need to loop sounds, I'm going to have a go at implementing it tonight.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3326
    • View Profile
    • Space Fractal
Yes are of that, but imperfect for multiplatform use, due framerate I set might variere. Etc its cannot allways checked just in time.

not sure it's can been done in a thread, but glbasic is not thread safe.
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.