#47514 - 21/11/2001 03:01
Sound overlay (mixing sound with players output)
|
member
Registered: 11/09/2000
Posts: 143
Loc: Jylland, Denmark
|
Hi,
Is it possible (of course, but how? :) to output some sound over the currently playing music.
What I wish to do is to lower the volume of the currently played music and play higher volume sample mixed in with that.
/dev/sound can only take input from one process at a time, right? Will this really need another hijack-style modification to work?
Any thoughts?
_________________________
Lars
MkII 40gig 090000598
|
Top
|
|
|
|
#47515 - 21/11/2001 07:35
Re: Sound overlay (mixing sound with players output)
[Re: Wire]
|
carpal tunnel
Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
|
Ummm /dev/mixer is what you want. I don't know the specifics but the Empeg can mix sounds, like when it does beeps. I'm not sure how it would handle playing two PCM sounds at the same time, but it sound possible.
|
Top
|
|
|
|
#47516 - 21/11/2001 10:23
Re: Sound overlay (mixing sound with players output)
[Re: Wire]
|
carpal tunnel
Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
|
If you are in control of the audio data stream (i.e., the actual bytes of raw 44.1khz audio sent to the DSP), then you can mix whatever you want in software before you send it to the outputs.
This is not implemented in the current software, you would have to write your own software to do it.
Whether or not you implement it in the kernel depends on what you want to do with it. The Voladj modification proves that the kernel certainly can get its mitts on the audio stream before it hits the DSP, the question is what are you trying to add to the sound?
If you are interested in mixing the microphone input with the player output, remember that there is a fairly low sampling rate on that mic input. You can't get high-fidelity sampling from the mic. I think it tops out at around 11khz. And the aux/tuner inputs are a no-go because they aren't routed in such a way as to allow sampling (if I recall correctly) and they can't be mixed directly.
|
Top
|
|
|
|
#47517 - 21/11/2001 17:55
voladj effects
[Re: tfabris]
|
old hand
Registered: 30/07/2000
Posts: 879
Loc: Germany (Ruhrgebiet)
|
Hi.
I just read this, and I wondered one thing.
The Voladj modification proves that the kernel certainly can get its mitts on the audio stream before it hits the DSP
I seem to remember that voladj does a (small) lookahead on the audio stream, which I only can imagine to be done using a small delay in the stream (i.e. cache x*4 Bytes (x/44100 seconds) of the stream, and then start playing the first byte while spooling the stream through that buffer).
If this is correct, doesn't that mean that with voladj, the visuals get out of sync with the audio (have a "lookahead" of x/44100 seconds)?
cu,
sven
_________________________
proud owner of MkII 40GB & MkIIa 60GB both lit by God and HiJacked by Lord
|
Top
|
|
|
|
#47518 - 21/11/2001 20:47
Re: voladj effects
[Re: smu]
|
member
Registered: 16/12/1999
Posts: 188
Loc: Melbourne, Australia
|
Nope. :)
The voladj stuff just uses the buffering that was already present in the kernel because I didn't want to increase the memory footprint. Up to 8 4608 byte blocks are buffered. But the voladj doesn't add new buffers, so the timing of the visuals is exactly the same with as without.
That's one potential area of improvement for the voladj code actually. Currently it only looks at most one block ahead. It could (maybe) look 5 blocks ahead, if that much data was buffered. But then I'd have to think very carefully about when things were allowed to be grabbed from the buffers. If I get some free time, that's on my list, along with working based on power rather than just maximum sample size.
Richard
|
Top
|
|
|
|
#47519 - 22/11/2001 08:37
Re: Sound overlay (mixing sound with players output)
[Re: tfabris]
|
member
Registered: 11/09/2000
Posts: 143
Loc: Jylland, Denmark
|
Hi,
No, do not wish to sample from the mic. I just wish to add playing of sounds concurrently with the player executable, at certain events.
Therefore I do not have control over the audio data stream.
_________________________
Lars
MkII 40gig 090000598
|
Top
|
|
|
|
#47520 - 22/11/2001 13:05
Re: Sound overlay (mixing sound with players output)
[Re: Wire]
|
carpal tunnel
Registered: 20/12/1999
Posts: 31597
Loc: Seattle, WA
|
Should be pretty easy to do in the kernel, then. Provided that the "events" are something you can control. For example, if you want it to play certain sounds every time you select a certain menu item, you probably can't do that because the player executable is not under your control.
|
Top
|
|
|
|
#47521 - 26/11/2001 15:34
Re: Sound overlay (mixing sound with players output)
[Re: tfabris]
|
carpal tunnel
Registered: 23/08/2000
Posts: 3826
Loc: SLC, UT, USA
|
Kim mentioned in this thread that he had mixed audio working with his nav software. You might want to ask him for details...
|
Top
|
|
|
|
#47522 - 26/11/2001 16:06
Re: Sound overlay (mixing sound with players output)
[Re: Wire]
|
enthusiast
Registered: 17/10/2001
Posts: 265
Loc: Portland OR
|
Hmmmm...
This sounds like this might be one of the missing links for the elusive CrossFade that so many of us are waiting for...
_________________________
DarioMK2 in an Impreza 2.5RS
|
Top
|
|
|
|
#47523 - 26/11/2001 16:41
Re: Sound overlay (mixing sound with players output)
[Re: Diznario]
|
carpal tunnel
Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
|
Not sure how this gets us to a cross-fading player app... Unless you're talking about having a second player running. Then you'd still need a way to control when one fades out and the other fades in...
IMHO cross-fading would really have to make its way into the player itself.
|
Top
|
|
|
|
#47524 - 26/11/2001 18:18
Re: Sound overlay (mixing sound with players output)
[Re: tonyc]
|
enthusiast
Registered: 17/10/2001
Posts: 265
Loc: Portland OR
|
IMHO cross-fading would really have to make its way into the player itself.
I totally agree. And no, I wasn't talking about having two empegs...
I was just making a sort of loose connection between what you are looking for, and what will need to happen to get crossfade to work.
I guess It's really just me dreaming about crossfading again. Pay no attention...
_________________________
DarioMK2 in an Impreza 2.5RS
|
Top
|
|
|
|
#47525 - 27/11/2001 09:52
Re: Sound overlay (mixing sound with players output)
[Re: loren]
|
member
Registered: 21/07/1999
Posts: 140
Loc: Helsinki, Finland
|
Kim mentioned in this thread that he had mixed audio working with his nav software. You might want to ask him for details...
Yes, I've done a small kernel mod to the empeg_audio3.c file which can read audio from secondary source and mix it into the player sound stream. It automatically fades the volumes, etc. Actually, it is even able to switch between tuner/pcm modes also so that if you output audio while you're in tuner mode, it'll fade the tuner volume down, switch to pcm, output the pcm, switch back to tuner and fade the volume up.
If people are interested, I can dig it up and build some sort of diff file to the current kernel empeg_audio3.c file. It probably should be get into riocar.org.
Kim
|
Top
|
|
|
|
#47526 - 27/11/2001 10:00
Re: Sound overlay (mixing sound with players output)
[Re: kim]
|
old hand
Registered: 30/07/2000
Posts: 879
Loc: Germany (Ruhrgebiet)
|
Hi Kim.
Please do so. That is a functionality that was requested quite often (actually, your mod does more, but hey, usefully so). If you could find the time to create the patch, I will find some time to add it (and some docs as needed) to the riocar.org developer section.
cu,
sven
_________________________
proud owner of MkII 40GB & MkIIa 60GB both lit by God and HiJacked by Lord
|
Top
|
|
|
|
#47527 - 27/11/2001 13:11
Re: Sound overlay (mixing sound with players output)
[Re: kim]
|
carpal tunnel
Registered: 27/06/1999
Posts: 7058
Loc: Pittsburgh, PA
|
Actually, it is even able to switch between tuner/pcm modes also so that if you output audio while you're in tuner mode, it'll fade the tuner volume down, switch to pcm, output the pcm, switch back to tuner and fade the volume up.
That is sweet. Me want. Me want badly. :)
|
Top
|
|
|
|
#47528 - 28/11/2001 05:14
Re: Sound overlay (mixing sound with players output)
[Re: smu]
|
member
Registered: 21/07/1999
Posts: 140
Loc: Helsinki, Finland
|
Ok, the patch file is attached to this post.
The patch file has been created against the v2.00-beta3 version of the kernel. The patching should go as follows:
% cd kernel/arch/arm/special
% patch < audio_overlay.patch
It modifies the empeg_audio3 and empeg_mixer files. The changes won't affect existing applications, therefore the player and other applications should run as before.
Using the audio overlay system is very simple. When you open the /dev/audio device in your code, you need to specify the O_SYNC flag to determine that you want to overlay audio with the player application.
For example:
int handle = open( "/dev/audio", O_WRONLY | O_SYNC );
That's all. Now, every time you write something to the handle, it will automatically fade the volumes and mix the audio.
Kim
Attachments
46906-audio_overlay.patch (267 downloads)
|
Top
|
|
|
|
#47529 - 28/11/2001 10:12
Re: Sound overlay (mixing sound with players output)
[Re: kim]
|
old hand
Registered: 30/07/2000
Posts: 879
Loc: Germany (Ruhrgebiet)
|
_________________________
proud owner of MkII 40GB & MkIIa 60GB both lit by God and HiJacked by Lord
|
Top
|
|
|
|
|
|