Setting sampling rate to 96 kHz

I am currently trying to set sampling rate to 96 kHz but seems like the internal sampling rate is still the default 48kHz. I currently have a simple arduino script where I have a microphone connected to in[0] and running peak frequency detection.

The correct peak frequency is only achieved when sampling_rate is set to 48000. Even when I change

hw = DAISY.init(DAISY_SEED, AUDIO_SR_96K);

to

hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);

or

hw = DAISY.init(DAISY_SEED, AUDIO_SR_32K);

there is no change in behavior. Why so? I followed the installation tutorials. Am I missing anything? This is the code.

// Import libraries
#include "DaisyDuino.h"
#include "arduinoFFT.h" 

// Daisy Hardware object
DaisyHardware hw;
const float multiplier = 10000;

// FFT object and parameters
const uint16_t samples = 1024;
const float sample_rate = 48000;
float vReal[samples];
float vImag[samples];
ArduinoFFT<float> FFT = ArduinoFFT<float>(vReal, vImag, samples, sample_rate);

// Variables for FFT processing
float fft_input_buffer[samples];
int fft_buffer_index = 0;
volatile float mic_level = 0.0f;
volatile float peak_frequency = 0.0f;
volatile float system_sr = 0.0f;

// Audio callback function
void MyCallback(float **in, float **out, size_t size) {
  float sum_of_squares = 0.0f;

  // Collect samples
  for (size_t i = 0; i < size; i++) {
    float sample = in[0][i];
    sum_of_squares += sample * sample;

    // If our FFT buffer has space, add the current sample to it
    if (fft_buffer_index < samples) {
      fft_input_buffer[fft_buffer_index] = sample;
      fft_buffer_index++;
    }
  }
  
  // Calculate RMS for volume level
  mic_level = sqrtf(sum_of_squares / size + 1e-9) * multiplier;

  // Perform FFT
  if (fft_buffer_index == samples) {
    // Copy the collected float samples into the double array for the FFT library
    for(int i = 0; i < samples; i++) {
        vReal[i] = fft_input_buffer[i];
        vImag[i] = 0.0; // Imaginary part is always 0 for real-world audio
    }

    FFT.windowing(FFTWindow::Hamming, FFTDirection::Forward);	/* Weigh data */
    FFT.compute(FFTDirection::Forward); /* Compute FFT */
    FFT.complexToMagnitude(); /* Compute magnitudes */
    peak_frequency = FFT.majorPeak();

    // Reset the buffer index to start collecting new samples
    fft_buffer_index = 0;
  }
}

void setup() {
  Serial.begin(9600); // Use a faster baud rate for more data
  
  hw = DAISY.init(DAISY_SEED, AUDIO_SR_96K); 
  system_sr = DAISY.get_samplerate();

  DAISY.begin(MyCallback); // Start the audio callback
}

void loop() {
  // Print the microphone level and peak frequency from the main loop
  Serial.print("System Sampling Rate: " + String(system_sr) + " Hz");
  Serial.print(" | Mic Level (RMS): " + String(mic_level));
  Serial.println(" | Peak Freq: " + String(peak_frequency) + " Hz");
  
  delay(100); 
}

Thanks!

The second arg to Init() is for setting the rate at which controls will be updated, not for setting the audio sample rate.

It looks to me like DaisyDuino only supports 48K.