Drum machine program in GLBasic using PLAYSOUND, Palm Pre problem..

Previous topic - Next topic

BdR

I'm trying to build a drum-machine-like program in GLBasic using PLAYSOUND as part of a rhythm game. The game will be bouncing a ball from tile to tile, and the music in the background stays in-sync with the bouncing of the ball. :)

I've programmed a drum-machine test program which can play a "track" (a simple textfile). The beat sounds okay on my Windows pc, but when I run it on my Palm Pre there's a slight stutter. It's not much but enough to notice the beat is not "tight". This is probably because the Palm-device isn't fast enough to play so many PLAYSOUND commands(?). It seems to run okay on my iPod4 device, so maybe it's due to slightly different screen refresh (60hz 50hz?), or are they the same? (and does it matter?) :doubt:

I've attached my tester program, see the "music synth" test part. The samples used are 44k 16bit mono, I've tried down-sampling them (with cooledit) to 22k and there seems to be a slight improvement on my palm, but still the "sequencer" speed seems a little uneven.

Any ideas on improving this? Maybe use a bigger sound buffer (how?), or use different sound commands (which ones?)

cheers,
Bas

[attachment deleted by admin]

Hemlos

Did you check out my thing on looping sounds perfectly?

In order to make it seemless(on PC anyhow) you need to run 4 buffers.
Im assuming since youre playing multiple sounds, this will be needed.
Bing ChatGpt is pretty smart :O

BdR

You mean this thread, but I'm not trying to loop a single breakbeat sound sample. Instead, my test program does several PLAYSOUND to create the drum sequence. Something like this:

PLAYSOUND basedrum
// after 0.25 sec
PLAYSOUND snare
// after 0.25 sec
PLAYSOUND basedrum
// after 0.25 sec
PLAYSOUND snare
etc.

In practice, combined with DRAWIMAGE and SHOWSCREEN etc. it doesn't play after 0.25 seconds (just example number) but sometimes noticably more or less. It doesn't seem to matter how many buffers I use with LOADSOUND for each instrument. The beat always sounds a little irregular or out of rhythm, at least on my Palm.

Hemlos

Read that thread carefully, i wrote about sound looping, yet...

I also explain how to make sounds seemless with a timer, and the additional buffers allow more than one sound at a time.
The idea...you must have your samples and timer perfect to take advantage of the buffers.
a beat is a beat, whether you play it once, or 10 times.
Bing ChatGpt is pretty smart :O

Hemlos

One other observation....you are doing a timed beat, that tutorial shows you how to make the timers specific to a standardized time.
You can run multiple standard time lengths with different types of sound too.
Some beat sample might be .25 seconds long, and you can do another group that are say 0.125 seconds long, or 0.5....all simultaneously.
Bing ChatGpt is pretty smart :O