[Freeswitch-users] Playing multiple files simultaneously
Bryan Smart
bryansmart at bryansmart.com
Wed Jul 6 21:35:09 MSD 2011
When I brought this up originally, I was considering possibilities for voice apps built on FS.
The long-standing user interface model for phone apps is like a voice version of a commandline. The app plays a linear stream of output, and then waits for you to respond. With rare exception, the only interface contexts that are widely used are a menu and a data entry prompt. If speech is involved, that increases the type of data that can be entered, but speech apps are usually the same: menus or data prompts.
With the capability of FS to globally bind digits and detect speech (so to know when to listen with a speech recognizer), it should be possible to create voice apps where digits and speech perform actions by raising events in the app, rather than being exclusively accepted by an input mechanism like a menu or data prompt. So far, I haven't run across voice apps that are designed using an event-driven model, at least in the way that desktop apps are designed. FS has got to be the place to prototype such apps, though. The whole system is event-based.
I know that it takes a stretch of the imagination to think of voice apps working in a new way. The phone has been stuck in a voice version of DOS for 25 or so years (since voicemail got a start as the first big voice app). Speech recognition has expanded possibilities for input, but has not changed the model of interface design.
I'm experimenting with what is possible with FS today. However, a more complex sound playback capability is needed to make a new type of audio interface possible.
An interface context, like a graphical desktop, can contain multiple objects. If a graphical object (icon) needs to notify the user of something, it generates a visual cue (flashes, changes color, adds a badge, and so on). Objects in an audio context need to notify, also, and they would do that by playing cues, speaking, etc. Those cues need to be able to partially overlap when played. New cues certainly shouldn't preempt older cues that haven't had a chance to play yet. Further, certain status cues should be heard, but must overlap currently playing audio, as it wouldn't be desirable for a status cue to interrupt the reading of an important message, for example.
So far, the only mixing environment in FS that I've been able to use is mod_conference, but that isn't ideal. To play multiple audio streams to a conference, it is necessary to connect multiple sessions to it, and treat them each like a sound source. One issue is that conference is meant to relay audio to everyone, and I can't help but think that these sound source sessions drain far too many resources. I've been setting them to deaf, so they should only relay audio in, but they might still be drawing more resources than necessary with detecting digits/speech, and other overhead that is part of every channel (I don't know the full list of what is involved). Plus, it just seems like a mistake to think of a voice app server where every incoming caller has their own conference, plus many sessions that exist to stream files to their conference. Maybe it wouldn't be as bad as it sounds.
I'm still trying to learn about FS internals, so I may have a good bit of the following wrong. Perhaps we could meet our needs by creating a module that exposed a new API command for playing sounds asynchronously on a channel. That way, the existing sound playback would continue to be lightweight. A voice app that worked through the event socket could use this module to handle playback and control of its sounds. Here are basic capabilities:
play: Should start playback of a sound, overlapping any existing sound previously requested through this command that has not finished playing. When playback starts, should return a unique ID for the sound instance (an event?). Optional playback parameters: volume/gain, start off set, loop count.
stop: Stops an existing sound instance from playing (by unique ID), or all sound instances.
change: Change sound instance parameters of an active sound instance: volume/gain, file position/time, loop count.
An event should be raised when any sound instance finishes playing. Should include info about cause: normal stop, manual stop, loop re-trigger, etc.
The module could handle the mixing, but it occurs to me that, looking ahead, it might be better to push a lot of that work out to another tech like OpenAL. After all, at some point, some clients might be connecting with 48Khz stereo audio. OpenAL supports positional audio and effects, in addition to raw mixing. OpenAL is available for several platforms, but not everywhere. Perhaps it would be more important to be widely available, at the cost of features.
Thoughts? Is a module the right way to go? Is using OpenAL a good idea, or should the module handle the mixing?
Bryan
On Jul 6, 2011, at 2:05 AM, broken dash wrote:
> I have been wanting these features and I found this...liquidsoap,
> check out the transcoding section. I was trying to play multiple
> shoutcast audio streams and hopefully mux them together nicely, etc..
> haven't gotten around to setting freeswitch to utilize it but I'm sure
> it wouldn't be hard.
>
> http://savonet.sourceforge.net/doc-1.0.0-beta2/cookbook.html
>
>
> Cheers,
> Brian
>
> On Fri, Jul 1, 2011 at 1:49 AM, Jan Berger <jan.berger at video24.no> wrote:
>> If you play several files FS will queue them if it is the same stream - you
>> need to somehow set up a conference with multiple streams (callers).
>>
>> I would check options around music on hold.
>>
>> But, another way is to use FS to play several outgoing SIP streams and loop
>> them back into a conference.
>>
>>
>> Jan
>>
>> -----Original Message-----
>> From: freeswitch-users-bounces at lists.freeswitch.org
>> [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Bryan
>> Smart
>> Sent: 1. juli 2011 07:13
>> To: FreeSWITCH Users Help
>> Subject: [Freeswitch-users] Playing multiple files simultaneously
>>
>> Is it possible for Freeswitch to play more than one file to a channel at a
>> time? What I've seen and tried from the dialplan and scripts either queues
>> files to play, or will stop a currently playing file so that the newly
>> requested file will play. This also seems to be the case in conferences.
>> When I send multiple play commands to conferences, the files are queued.
>>
>> As for how this might be used, think of an IVR that plays queued prompts,
>> yet continuously plays looping music or a Shoutcast stream in the
>> background. I also want to be able to play short cue tones that start at the
>> same time as a prompt (don't want to pre-mix them in to a single file,
>> though).
>>
>> Is this currently possible through any means? Perhaps with the event socket?
>>
>> Bryan
>>
>>
>> _______________________________________________
>> Join us at ClueCon 2011, Aug 9-11, Chicago
>> http://www.cluecon.com 877-7-4ACLUE
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>>
>> _______________________________________________
>> Join us at ClueCon 2011, Aug 9-11, Chicago
>> http://www.cluecon.com 877-7-4ACLUE
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org
>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
>> http://www.freeswitch.org
>>
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicago
> http://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
More information about the FreeSWITCH-users
mailing list