Notice: A non well formed numeric value encountered in /sites/ on line 96 Notice: A non well formed numeric value encountered in /sites/ on line 96 Notice: A non well formed numeric value encountered in /sites/ on line 96 Deprecated: Function create_function() is deprecated in /sites/ on line 104 Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /sites/ on line 845 Deprecated: Function create_function() is deprecated in /sites/ on line 111 FS#11232 : Mix pcm and voice in software



FS#11232 - Mix pcm and voice in software

Attached to Project: Rockbox
Opened by Jeffrey Goode (Blue_Dude) - Friday, 30 April 2010, 20:35 GMT
Last edited by Jeffrey Goode (Blue_Dude) - Wednesday, 08 June 2011, 21:22 GMT
Task Type Patches
Category Music playback
Status Closed
Assigned To No-one
Operating System SW-codec
Severity Low
Priority Normal
Reported Version Release 3.4
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


This is a work in progress. It compiles in the sim but isn't nearly ready for committing yet.

I'm attempting to mix pcm and voice just-in-time for playback. This patch creates two small buffers and shrinks an existing buffer to almost nothing (most is currently wasted anyway). The two new buffers are 1024 sample mixing buffers that are mixed by calls from the voice thread. One is the active playing buffer while the other is on standby being mixed. The correct buffers are fed to the DMA automatically when the mixer is enabled.

I've tried to keep the mixer ISR callback that actually feeds the DMA small and light, but it remains to be seen whether it runs fast enough on target without draining the DMA FIFO buffer first. It's possible that some of the callback will have to implemented in ASM or otherwise rewritten.

Not yet implemented:

Playback pause behavior. After hitting pause while mixing, playback will continue until the currently playing mix buffer finished, to avoid cutting off voice playback, then swap to aux only playback seamlessly.

Pause/resume fade. This currently happens in hardware. Making this happen in the callback hasn't been addressed. Making it work in the callback along with the "rewind" feature hasn't been looked at yet either.

This task depends upon

Closed by  Jeffrey Goode (Blue_Dude)
Wednesday, 08 June 2011, 21:22 GMT
Reason for closing:  Rejected
Additional comments about closing:  Better solution available at  FS#12150 
Comment by Jeffrey Goode (Blue_Dude) - Sunday, 02 May 2010, 18:45 GMT
Also not yet implemented:

pcmbuf_beep, aka the keyclick function. It currently mixes-in-place in the pcm buffer, but it ought to write to, or maybe be mixed with, the aux buffer instead.
Comment by Jeffrey Goode (Blue_Dude) - Tuesday, 07 December 2010, 17:25 GMT
I haven't been able to work on this for several months. I did considerable work since uploading the first patch, but it's still very much a work in progress. I've synced the patch with r28762, but it probably won't compile cleanly. It's been so long I don't remember. I'm uploading this patch in the hope that someone will find it useful as a starting point for further development. Maybe I'll be able to develop it further but I don't know when that will be.

The purpose of this patch was to intercept the normal DMA playback and redirect it to a very small mixing buffer that would mix playback and voice in real time with very low latency. It would get away from mixing voice into the playback buffer as that would prevent resuming playback after a pause cleanly. Instead, it meant to establish two very small mixing buffers, one active and the other standby. The DMA would point to the active one and the other would be mixing in the background. When the DMA was starved for data, the roles would automatically switch. This causes a lot of DMA interrupts but it would only occur if data and voice were playing at the same time. If no voice was playing, then playback operates normally.

I also renamed voice playback to aux playback, in the hopes that it would open up audio insertion to other types of audio than merely voice assistance, such as custom sound files or game sounds.
Comment by Jeffrey Goode (Blue_Dude) - Monday, 09 May 2011, 22:09 GMT
Synced to r29850.