Commit Graph

32 Commits

Author SHA1 Message Date
Solomon Peachy 388adff3cc pcm: Further cleanup of unused bits of the PCM ACPI:
* pcm_get_bytes_remaining()
 * pcm_calculate_peaks()
 * pcm_get_peak_buffer()

Nothing in-tree uses these at all (except for the lua plugin wrapper)

Change-Id: I971b7beed6760250c8b1ce58f401a601e1e2d585
2020-11-12 15:59:09 +00:00
Solomon Peachy fe2d52cc7d pcm: Get rid of pcm_play_pause() and associated APIs
Nothing in the core has used it for some time.  It's exported to the
plugin API but the last plugins to use it were switched to the mixer API
back in 2011.

This allows us to get rid of pcm_play_dma_pause() from all audio drivers

Change-Id: Ic3fa02592316f84963e41d792d1cabb436d1ff6b
2020-10-31 01:18:27 +00:00
Michael Sevakis 61d0583384 Greatly reduce volume-change zipper artifacts with SW volume.
Uses a cosine factor to smoothly shift the PCM level from the old level
to the new one over the length of a frame.

Implements indirect calls to PCM scaling function instead of testing
conditions on every callback, cleanly assigning a different call to
do the volume transition. The volume change call then assigns the final
scaling function.

Change-Id: If1004b92a91c5ca766dd0e4014ec274636e8ed26
Reviewed-on: http://gerrit.rockbox.org/763
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested: Michael Sevakis <jethead71@rockbox.org>
2014-03-08 08:04:41 +01:00
Michael Sevakis d37bf24d90 Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency.

The user may select 48000Hz if the hardware supports it. The default is
still 44100Hz and the minimum is 44100Hz. The setting is located in the
playback settings, under "Frequency".

"Frequency" was duplicated in english.lang for now to avoid having to
fix every .lang file for the moment and throwing everything out of sync
because of the new play_frequency feature in features.txt. The next
cleanup should combine it with the one included for recording and
generalize the ID label.

If the hardware doesn't support 48000Hz, no setting will be available.

On particular hardware where very high rates are practical and desireable,
the upper bound can be extended by patching.

The PCM mixer can be configured to play at the full hardware frequency
range. The DSP core can configure to the hardware minimum up to the
maximum playback setting (some buffers must be reserved according to
the maximum rate).

If only 44100Hz is supported or possible on a given target for playback,
using the DSP and mixer at other samperates is possible if the hardware
offers them.

Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622
Reviewed-on: http://gerrit.rockbox.org/479
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-07-06 04:22:04 +02:00
Michael Sevakis 08199cd6cb Provide high resolution volume and prescaler to hosted targets.
HAVE_SW_VOLUME_CONTROL is required and at this time only affects the
SDL targets using pcm-sdl.c.

Enables balance control in SDL targets, unless mono volume is in use.

Compiles software volume control as unbuffered when
PCM_SW_VOLUME_UNBUFFERED is defined. This avoids the overhead and
extra latency introduced by the double buffer when it is not needed.
Use this config when the target's PCM driver is buffered and sufficient
latency exists to perform safely the volume scaling.

Simulated targets that are double-buffered when made as native targets
remain so in the sim in order to run the same code.

Change-Id: Ifa77d2d3ae7376c65afecdfc785a084478cb5ffb
Reviewed-on: http://gerrit.rockbox.org/457
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-04-27 06:59:27 +02:00
Michael Sevakis f5a5b94686 Implement universal in-PCM-driver software volume control.
Implements double-buffered volume, balance and prescaling control in
the main PCM driver when HAVE_SW_VOLUME_CONTROL is defined ensuring
that all PCM is volume controlled and level changes are low in latency.

Supports -73 to +6 dB using a 15-bit factor so that no large-integer
math is needed.

Low-level hardware drivers do not have to implement it themselves but
parameters can be changed (currently defined in pcm-internal.h) to work
best with a particular SoC or to provide different volume ranges.

Volume and prescale calls should be made in the codec driver. It should
appear as a normal hardware interface. PCM volume calls expect .1 dB
units.

Change-Id: Idf6316a64ef4fb8abcede10707e1e6c6d01d57db
Reviewed-on: http://gerrit.rockbox.org/423
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2013-04-11 22:55:16 +02:00
Michael Sevakis e189b33ff4 Clean up peak calculating code.
Mixer needn't keep peak data around that will never be used. Just
pass pcm_peaks structure to it instead of allocating for every
channel. Plugin API becomes incompatible.

vu_meter digital mode was still using global peak calculation;
switch it to playback channel like the rest.

Remove some accumulated soil peaks inside pcm.c and make it more
generic.

Change-Id: Ib4d268d80b6a9d09915eea1c91eab483c1a2c009
2012-05-02 20:53:07 -04:00
Michael Sevakis 286a4c5caa Revise the PCM callback system after adding multichannel audio.
Additional status callback is added to pcm_play/rec_data instead of
using a special function to set it. Status includes DMA error
reporting to the status callback. Playback and recording callback
become more alike except playback uses "const void **addr" (because
the data should not be altered) and recording  uses "void **addr".
"const" is put in place throughout where appropriate.

Most changes are fairly trivial. One that should be checked in
particular because it isn't so much is telechips, if anyone cares to
bother. PP5002 is not so trivial either but that tested as working.

Change-Id: I4928d69b3b3be7fb93e259f81635232df9bd1df2
Reviewed-on: http://gerrit.rockbox.org/166
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
2012-03-03 07:23:38 +01:00
Michael Sevakis e42a3194de AS3525v1/v2:
Fix problems with volume of recorded material by converting 14-bit samples to
16-bit. Remove duplicate samples from recorded data and support proper
samplerate since ADC runs 1/2 the codec clock. Support monitoring mono on both
output channels by feeding data manually to I2SOUT under the right conditions.

DMA is no longer used for recording since frames must be processed as described
above but it does allow full-duplex audio.

Miscellaneous change includes a proper constant (HW_SAMPR_DEFAULT) to reset the
hardware samplerate when recording is closed. PP5024 and AS3525 have different
default recording rates (22kHz and 44kHz respectively) but both have half-speed
ADC.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31180 a1c6a512-1295-4272-9138-f99709370657
2011-12-08 19:20:00 +00:00
Michael Sevakis 906905aa43 Use a macro for aligning PCM chunks instead of explictly coding it each time.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31152 a1c6a512-1295-4272-9138-f99709370657
2011-12-05 13:58:35 +00:00
Michael Sevakis 4db3e89652 Shuffle some functions around so that interfacing with playback.c in particular isn't required. Though playback does finish the audio init, pcm doesn't care who does it.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30403 a1c6a512-1295-4272-9138-f99709370657
2011-09-01 12:15:43 +00:00
Michael Sevakis 22b6def065 Use playback channel directly for peakmeters and plugins using peak calculation. Also, for now, don't allow mixer playback to overlap recording, even if full duplex works.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30119 a1c6a512-1295-4272-9138-f99709370657
2011-07-02 11:55:38 +00:00
Michael Sevakis a2b6703a36 Commit FS#12150 - Fully-functional audio mixer - and finally whip old limitations about playback of voice and other sounds when paused. Channels are independent in state and amplitude. Fade on stop/pause is handled by the channel's volume control rather than global volume which means it now works from anywhere. Opens up the possibility of plugin sounds during music playback by merely adding an additional channel enum. If any PCM drivers were not properly modified, see one of the last comments in the task for a description of the simple change that is expected. Some params are tunable in firmware/export/pcm-mixer.h as well.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30097 a1c6a512-1295-4272-9138-f99709370657
2011-06-29 06:37:04 +00:00
Frank Gevaerts d343bbe846 Allow e200 to compile without HAVE_RECORDING
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28104 a1c6a512-1295-4272-9138-f99709370657
2010-09-17 20:42:45 +00:00
Michael Sevakis e0bb92f00f Should clear up rest of red. Add a required #define in the config for c200. Fix up some preprocessing directives. Hope it's all taken care of now.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27141 a1c6a512-1295-4272-9138-f99709370657
2010-06-26 10:37:41 +00:00
Michael Sevakis b15a523870 e200v1/c200v1: Implement limited samplerate switching. Rates 24kHz and below are being a bear as far as minor crackling at higher amplitude-- leave them out for the time being since no solution is currently evident. 48, 44, 32 (rec rates 24, 22, 16) seem perfectly fine. I'm betting c200 is ok to include because it uses the same setup as e200.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27139 a1c6a512-1295-4272-9138-f99709370657
2010-06-26 10:07:17 +00:00
Michael Sevakis d56999890f Make PCM->driver interface about as simple as it will get. Registered callback, zero data, alignment and stops are handled entirely inside pcm.c; driver merely calls fixed pcm.c callback. Remove pcm_record_more and do it just like playback; the original reason behind it isn't very practical in general. Everything checks out on supported targets. There wer some compat changes I can't check out on many unsupoorted but if there's a problem it will be a minor oops. Plugins become incompatible due to recording tweak-- full update. Sorted API.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26253 a1c6a512-1295-4272-9138-f99709370657
2010-05-24 16:42:32 +00:00
Michael Sevakis 18c7e0eba4 Trim down peak calculation a bit.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25978 a1c6a512-1295-4272-9138-f99709370657
2010-05-13 04:12:23 +00:00
Michael Sevakis 4d04132c76 PCM bottom layer simplification. pcm_rec_peak_addr variable no longer has to be handled there. Driver can just return current pointer for recording peaks. A new define, HAVE_PCM_REC_DMA_ADDRESS, specifies that physical addresses are being used for recording and translation is needed before starting a new block. The drivers need not worry about aligning start and size nor should care if either will be zero. All this will be checked in the logical layer first.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25970 a1c6a512-1295-4272-9138-f99709370657
2010-05-12 14:05:36 +00:00
Rafaël Carré f2f34881ec Remove pcm_mute() which has been unused since r19308
Remove audiohw_mute from header as well, and make this function static
to each driver (commented out when it was unused)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25733 a1c6a512-1295-4272-9138-f99709370657
2010-04-27 00:05:02 +00:00
Frank Gevaerts 43264a946f New plugin: FFT, A frequency analyzer plugin
There is some more work needed:
- Keymaps are definitely not perfect, touchscreen targets are disabled due to no keymap
- There is no manual yet

Author: Delyan Kratunov 
Flyspray: FS#10065



git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24587 a1c6a512-1295-4272-9138-f99709370657
2010-02-10 19:44:11 +00:00
Jeffrey Goode faa47bf1b7 Code cleanup in dsp.c and misc.c, some comments
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23314 a1c6a512-1295-4272-9138-f99709370657
2009-10-22 00:59:42 +00:00
Michael Sevakis 94537f954e Gigabeat S: Implement an SDMA API and use it in the PCM driver. Some other miscellaneous adjustments to recording and PCM buffer to accomodate use of physical addresses and cache coherency.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19949 a1c6a512-1295-4272-9138-f99709370657
2009-02-08 22:32:41 +00:00
Michael Sevakis 26bf32c8aa Check that PCM is playing/recording *after* getting the current position from the hardware layer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19435 a1c6a512-1295-4272-9138-f99709370657
2008-12-14 11:42:47 +00:00
Michael Sevakis 93572e2a9e Keyclick fixup take two. It is only 88 samples (2msec) long so keep a small static buffer around for beeps less than or equal to keyclick duration. This way it operates no matter the buffer state and still won't interfere with alternate PCM operations like recording or plugin playback.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19415 a1c6a512-1295-4272-9138-f99709370657
2008-12-13 06:01:08 +00:00
Michael Sevakis b6e78acc5e Get rid of some pcm_apply_settings cruft at the low level I somehow missed. Move the ones in pcm.c around to better spots. Remove a variable from pcm-pnx0101.c that should no longer be there.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19402 a1c6a512-1295-4272-9138-f99709370657
2008-12-12 12:46:57 +00:00
Michael Sevakis e69d567d9e Bring consistency to pcm implementation and samplerate handling. Less low-level duplication. A small test_sampr fix so it works on coldfire again.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19400 a1c6a512-1295-4272-9138-f99709370657
2008-12-12 11:01:07 +00:00
Rob Purchase 4d97165bf6 Fix a slightly misleading logf
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18026 a1c6a512-1295-4272-9138-f99709370657
2008-07-13 17:34:58 +00:00
Daniel Stenberg 2acc0ac542 Updated our source code header to explicitly mention that we are GPL v2 or
later. We still need to hunt down snippets used that are not. 1324 modified
files...
http://www.rockbox.org/mail/archive/rockbox-dev-archive-2008-06/0060.shtml


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17847 a1c6a512-1295-4272-9138-f99709370657
2008-06-28 18:10:04 +00:00
Michael Sevakis 05099149f1 Enable nocache sections using the linker. PP5022/4 must use SW_CORELOCK now with shared variables in DRAM (it seems swp(b) is at least partially broken on all PP or I'm doing something very wrong here :\). For core-shared data use SHAREDBSS/DATA_ATTR. NOCACHEBSS/DATA_ATTR is available whether or not single core is forced for static peripheral-DMA buffer allocation without use of the UNCACHED_ADDR macro in code and is likely useful on a non-PP target with a data cache (although not actually enabled in config.h and the .lds's in this commit).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16981 a1c6a512-1295-4272-9138-f99709370657
2008-04-06 04:34:57 +00:00
Michael Sevakis 0553385bd2 Still on the post-big-commit policing. Correct a function call order. Comment a couple things.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15031 a1c6a512-1295-4272-9138-f99709370657
2007-10-07 23:19:09 +00:00
Michael Sevakis 6077e5b7c8 Unify PCM interface just above the hardware driver level for all targets including the sims. Perform lockout of audio callback when changing states. Weird new playback or recording trouble? Check before and after this revision first though things seem quite sound.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15006 a1c6a512-1295-4272-9138-f99709370657
2007-10-06 22:27:27 +00:00