maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [N900] How to play more than one sample at the same time? (https://talk.maemo.org/showthread.php?t=57637)

soeiro 2010-07-02 13:09

[N900] How to play more than one sample at the same time?
 
Hello folks

What is the best approach to play more than one sample at the same time on the N900? I'm open to Python, plain C/C++ or QT.

Using pyGame I can play a sound file, but it seems to allow just one at a time.

I can write a code in C that mixes many files into a buffer and then sends that to the appropriate (however it may be) sound device. But I'm wondering if there is already something done or more appropriate.

The ideal solution would be a simple API call that started the playing in background, returning immediately to the calling program.

Any hints?

mikec 2010-07-02 13:28

Re: [N900] How to play more than one sample at the same time?
 
pygmae channel.play . upto 500 channels on N900. have a look at maesynth in extras dev, which is fully polyphonic, though has some slight timing issues.

soeiro 2010-07-02 16:57

Re: [N900] How to play more than one sample at the same time?
 
Quote:

Originally Posted by mikec (Post 738580)
pygmae channel.play . upto 500 channels on N900. have a look at maesynth in extras dev, which is fully polyphonic, though has some slight timing issues.

Thanks. I've found out that there is this small delay, too. How do you do to pre-cache the file so that it plays on time?

mikec 2010-07-02 19:27

Re: [N900] How to play more than one sample at the same time?
 
Quote:

Originally Posted by soeiro (Post 738759)
Thanks. I've found out that there is this small delay, too. How do you do to pre-cache the file so that it plays on time?

You need to set the buffer size on the mixer a bit smaller. The bigger it is the bigger the delay. also helps to have you wav file at 48000 sample rate.

Where you want two samples playing at exactly the same time, I'am having to premix two sounds using sndarrays before I play them. Works pretty good, and surprisingly fast using python Numeric. Numpy would be great but is currently broken on the N900 on pygame.


All times are GMT. The time now is 12:02.

vBulletin® Version 3.8.8