Mercurial > hg > beaglert
changeset 178:a156a694864d
-p flag now indicates the buffer size in audio samples. Closes #1520
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Sat, 02 Jan 2016 13:08:39 +0100 |
parents | 3b364fb8c4ee |
children | f1012082f142 |
files | core/RTAudio.cpp core/RTAudioCommandLine.cpp |
diffstat | 2 files changed, 17 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/core/RTAudio.cpp Mon Dec 28 17:50:51 2015 +0100 +++ b/core/RTAudio.cpp Sat Jan 02 13:08:39 2016 +0100 @@ -80,8 +80,10 @@ // initAudio() prepares the infrastructure for running PRU-based real-time // audio, but does not actually start the calculations. -// periodSize indicates the number of _sensor_ frames per period: the audio period size -// is twice this value. In total, the audio latency in frames will be 4*periodSize, +// periodSize indicates the number of audio frames per period: the analog period size +// will depend on the number of analog channels, in such a way that +// analogPeriodSize = 4*periodSize/numAnalogChannels +// In total, the audio latency in frames will be 2*periodSize, // plus any latency inherent in the ADCs and DACs themselves. // useAnalog indicates whether to enable the ADC and DAC or just use the audio codec. // numAnalogChannels indicates how many ADC and DAC channels to use. @@ -142,35 +144,33 @@ else settings->numAnalogChannels = 2; - // Sanity check the combination of channels and period size - if(settings->numAnalogChannels <= 4 && settings->periodSize < 2) { - cout << "Error: " << settings->numAnalogChannels << " channels and period size of " << settings->periodSize << " not supported.\n"; - return 1; - } - if(settings->numAnalogChannels <= 2 && settings->periodSize < 4) { - cout << "Error: " << settings->numAnalogChannels << " channels and period size of " << settings->periodSize << " not supported.\n"; - return 1; - } - // Initialise the rendering environment: sample rates, frame counts, numbers of channels gContext.audioSampleRate = 44100.0; gContext.audioChannels = 2; if(settings->useAnalog) { - gContext.audioFrames = settings->periodSize * settings->numAnalogChannels / 4; + gContext.audioFrames = settings->periodSize; - gContext.analogFrames = settings->periodSize; + gContext.analogFrames = gContext.audioFrames * 4 / settings->numAnalogChannels; gContext.analogChannels = settings->numAnalogChannels; gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)settings->numAnalogChannels; } else { - gContext.audioFrames = settings->periodSize * 2; + gContext.audioFrames = settings->periodSize; gContext.analogFrames = 0; gContext.analogChannels = 0; gContext.analogSampleRate = 0; } + // Sanity check the combination of channels and period size + if( (gContext.analogChannels <= 4 && gContext.analogFrames < 2) || + (gContext.analogChannels <= 2 && gContext.analogFrames < 4)) + { + cout << "Error: " << gContext.analogChannels << " channels and period size of " << gContext.analogFrames << " not supported.\n"; + return 1; + } + // For now, digital frame rate is equal to audio frame rate if(settings->useDigital) { gContext.digitalFrames = gContext.audioFrames; @@ -200,7 +200,7 @@ } // Get the PRU memory buffers ready to go - if(gPRU->initialise(0, settings->periodSize, settings->numAnalogChannels, true)) { + if(gPRU->initialise(0, gContext.analogFrames, gContext.analogChannels, true)) { cout << "Error: unable to initialise PRU\n"; return 1; }
--- a/core/RTAudioCommandLine.cpp Mon Dec 28 17:50:51 2015 +0100 +++ b/core/RTAudioCommandLine.cpp Sat Jan 02 13:08:39 2016 +0100 @@ -48,7 +48,7 @@ void BeagleRT_defaultSettings(BeagleRTInitSettings *settings) { // Set default values for settings - settings->periodSize = 8; + settings->periodSize = 16; settings->useAnalog = 1; settings->useDigital = 1; settings->numAnalogChannels = 8;