Skip to content

analog input 88200 Hz (88.2 kHz, 2 channels) broken #717

@claudeha

Description

@claudeha

I am trying to do some experiments with ultrasound. I found that analog input 2 channels at 88200 was reporting the same block size as the audio at 44100, and analogRead() was returning 0 for the second half of the expected block size:

printf("%d @ %f | %d / %d @ %f\n", context->audioFrames, double(context->audioSampleRate), context->analogInChannels, context->analogFrames, double(context->analogSampleRate));

in setup() was printing

64 @ 44100.000000 | 2 / 64 @ 88200.000000

which is obviously inconsistent.

I made a small change to core/RTAudio.cpp and am now getting much more sensible behaviour:

root@bela:~/Bela# cat -n core/RTAudio.cpp | grep -C3 Claude
   677			gContext.analogInChannels = std::min((int)cfg.analogInChannels, settings->numAnalogInChannels);
   678			unsigned int numAnalogChannelsForSampleRate = gContext.analogInChannels;
   679			gContext.analogSampleRate = gContext.audioSampleRate * 4.0 / (float)numAnalogChannelsForSampleRate;
   680	//		// FIXME changed by Claude Heiland-Allen 2023-04-28
   681	//		gContext.analogFrames = gContext.audioFrames / (int)(gContext.audioSampleRate / gContext.analogSampleRate + 0.5f);
   682			gContext.analogFrames = gContext.audioFrames * gContext.analogSampleRate / gContext.audioSampleRate;
   683			gContext.audioExpanderEnabled = (settings->audioExpanderInputs & 0xFFFF) |

my setup() now prints

64 @ 44100.000000 | 2 / 128 @ 88200.000000

and the scopes look much more sensible.

(If you really want I could do a github pull request dance for your entertainment...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions