Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
claudeha opened this issue Apr 28, 2023 · 0 comments
Open

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

claudeha opened this issue Apr 28, 2023 · 0 comments

Comments

@claudeha
Copy link

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...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant