View Full Version : Playing multiple voices
04-01-2005, 08:58 AM
I am trying to determine the correct mechanism for playing multiple sounds at the same time through OpenML.
On the application side, I'm guessing that we need to open multiple paths with mlOpen().Would those specify the same pathID on input? (Or how far back in the chain do we need to have multiple instances for?)
Internally in the ML audio devices, I'm also wondering how mixing is handled. I see references to dev/mixer in the Linux code base but don't have any experience with Linux and have not yet tried to follow how that device is being used. By comparison, there don't appear to be any references to mixing at all in the winaudio device. Is this assuming that any contemporary Windows audio solution supports multiple voices in hardware? What happens when running on a WinCE device that only supports a single voice? Is there an entry in the capabilities tree for how many voices the hardware supports?
04-01-2005, 01:10 PM
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>Originally posted by John Harris:
On the application side, I'm guessing that we need to open multiple paths with mlOpen().
In my system, The ML module of my audio card has only one output jack and path. So i can only open one output path with mlOpen.But i believe that there's a soultion:
As an example i have 2 sound files named 1.wav and 2.wav and 10 buffers .The capacity of each buffer is 512 bytes. Now i copy the first 512 bytes of the file 1.wav in the first buffer; the first 512 bytes of the file 2.wav in the second buffer; the second 512 bytes of the file 1.wav in the third buffer; the second 512 bytes of the file 2.wav in the fourth buffer and so on. But i don't know that if it produces a smooth result on the output?
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>Would those specify the same pathID on the input?
If your module has more than one output path, then each of them has it's own ID.Also input paths have their own ID.
MLU has a utility function that can find the path ID:
mluFindPathFromJack( MLint64 jackId, MLint64* pathId, MLint32* memAlignment )
If you know the output-or input- jack ID, then this function finds the path ID of that jack.
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR>Is there an entry in the capabilities tree for how many voices the hardware supports?
I can't understand the meaning of the *voice* in your sentence--The output audio path is probbaly the issue, i.e.
First of all, you need to know that which module is the audio module.ML capabilities tree doesn't explicitly say that "It's an audio module".you should query the features of each module to find the audio module--If there's an audio moudle.Then you can query the number of the output paths of this module.
I believe that this discussion is useful for you:
IF we want to play the sound by OpenML, we must ensure that there's an module that can do this. As i have studied the source codes of the audioToFile and FileToAudio examples, the user should specify the name of the module to start the action.
But In a real application, the application should find the appropriate module and start the action.
My problem is that the module names aren't same for different cards(?)How can i understand that there's an OpenML module that can captures and transports the audio data?
You can query the capabilities, and find out what supports audio paths. Start by querying the system, to get a list of devices, then query each device. Look at the code for mlquery (included in the SDK release) -- this is exactly how it lists all the devices present on your system.
[ April 02, 2005: Message edited by: Ehsan Kamrani ]
04-02-2005, 08:56 PM
"Voice" is a term that refers to how many sounds you can play at the same time.
Most audio hardware has the capability of playing multiple sounds, and audio APIs typically do one of two things:
- The application allocates multiple instances of whatever entity is required to manage multiple concurrent sounds.
- The API automatically allocates free voices when processing play commands.
The queuing structure of OpenML already rules out the second alternative. Additional mlSendBuffers() get processed sequentially rather than mixed concurrently. The question, is whether some form of the first alternative exists in OpenML. So far, it doesn't seem to, which leaves me wondering how to play multiple concurrent sounds.
The second part of the question, is that if the application wants to play more concurrent sounds than the hardware supports, some form of software mixing has to take place. (Multiple sound samples are merged into a single audio stream). The previously mentioned Linux device dev/mixer now looks like it has nothing to do with mixing multiple voices of PCM audio, but rather mixing different audio sources together. So perhaps no form of software mixing exists in the current OpenML implementation.
So in summary, I need to find out how to play multiple concurrent sounds through the hardware's PCM mixing capability. I also need to be able to determine how many hardware voices exist, so that I know when I need to pre-mix samples in software. (Assuming there's no such capability somewhere in OpenML that I haven't spotted yet).
04-03-2005, 12:22 AM
I should add another question to this topic:
OpenML specification says:
A single path can have more than one instance. Depending on the device, it is possible for several instances of a path to be open and in use concurrently.
What does this mean?
04-03-2005, 07:58 AM
<BLOCKQUOTE><font size="1" face="Arial, Verdana, Helvetica, sans-serif">quote:</font><HR> Depending on the device, it is possible for several instances of a path to be open and in use concurrently.<HR></BLOCKQUOTE>
I have tried this and could not accomplish what I was after. The winaudio device accepted multiple mlOpen() calls without an error, however all of those calls returned the same value for hPath. So I didn't end up with multiple instances.
04-04-2005, 03:26 AM
this is a good question. At first glance, it would seem that ML does not support multiple voices and hardware mixing (but I'm no audio expert, so I could be wrong). In this case, the application would have to do all its mixing in software... I'll see if I can find out more info.
But perhaps the solution *could* be related to Ehsan's question (which you tried already): opening the same path multiple times. One could imaging that a device could support this by mixing the samples from each path... but this would have to be implemented in the ML module (not done in the current sample modules). And as you say, it would require a new capability to inform the application on the number of voices that can be used.
Ehsan, to answer your question: I don't really know what is meant by that quote. I haven't yet seen a situation where multiple instances of a path are opened. For input paths, it could mean the application could receive two streams of buffers from the same source.
04-22-2005, 04:08 PM
So can you contact with the authors of the ML specification and collect some information for us about this subject.It's a major problem If we can not open multiple instances of an output path. It means that we can not use the OpenML in the games, we cannot mix sounds, etc.
04-22-2005, 11:49 PM
Apparently, I was doing something wrong in my initial tests because ML does support opening multiple paths, and the winaudio device does play multiple concurrent sounds.
Sorry for my earlier misinformation.
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.