Ok, while testing I've come to a weird point. I made clock speed being adjusted by a pot, and swept down from 600 MHz to 150 MHz, with 50 MHz steps. Code lights leds when available() methods return true, so that I can see.
When the speed input to set_arm_clock and the speed read back from F_CPU_ACTUAL are the same, ADC-related peak and FFT work, but when not the same, they don't

So, among sweep speeds, only 600, 450 and 300 MHz works, while I sweep up and down.
As a workaround trial, if I add an exception for setting 150 MHz, to set speed to 151200000 (which is F_CPU_ACTUAL reading when set_arm_clock with 150 MHz), peak and FFT still don't work, even at this case set_arm_clock input and F_CPU_ACTUAL are the same.
Playing wav from SD card through MQS always works. And, as
@defragster stated, peak works and has nothing to do with this, since it just cannot get data from ADC. So, this issue relates to AudioInputAnalog I guess. I can live with finding the lowest possible speed that AudioInputAnalog works, but will dig this a bit deeper, out of curiosity.
Compiling with 150 MHz selected from the IDE as CPU speed, and without even calling set_arm_clock once, ADC-related results don't work as above


And while sweeping up from 150 MHz to 600 MHz, they continue never giving results, even at steps where set_arm_clock input and F_CPU_ACTUAL reading are the same.
Below is the output from sweeping down, with code compiled with 600 MHz selected from the IDE as CPU speed, writing gear no (by dividing pot range to 10

), set_arm_clock input and F_CPU_ACTUAL reading. Peak and FFT works at gears 9, 6 and 3 only.
Code:
setup OK
9
600000000
600000000
8
550000000
552000000
7
500000000
498000000
6
450000000
450000000
5
400000000
402000000
4
350000000
348000000
3
300000000
300000000
2
250000000
252000000
1
200000000
201000000
0
150000000
151200000
Here is the code for completeness, with aforementioned exception for 150 MHz (gear 0) is commented out:
C++:
#include <Bounce.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=588,233
AudioInputAnalog adc1; //xy=629,374
AudioAmplifier amp1; //xy=764,232
AudioAnalyzePeak peak1; //xy=852,358
AudioAnalyzeFFT256 fft256_1; //xy=853,413
AudioOutputMQS mqs1; //xy=939,230
AudioConnection patchCord1(playSdWav1, 0, amp1, 0);
AudioConnection patchCord2(adc1, peak1);
AudioConnection patchCord3(adc1, fft256_1);
AudioConnection patchCord4(amp1, 0, mqs1, 0);
// GUItool: end automatically generated code
// Use these with the Teensy 3.5 & 3.6 & 4.1 SD card
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
// pin assignments
// AudioInputAnalog uses pin A2 by default
const uint8_t pinButton = 0, pinYellow = 41, pinRed = 40, pinGreen = 39, pinPot = A4;
// button debounce time in ms, increase if button output still chatters
const int debounceTime = 20;
// buttons
Bounce button = Bounce(pinButton, debounceTime);
// clock speed entities
extern "C" uint32_t set_arm_clock(uint32_t frequency);
// frequency of the basis crystal for the system clock is 24 MHz
const uint32_t minSpeed = 150000000;
int currentGear;
void setup() {
Serial.begin(9600);
AudioMemory(8);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(1000);
}
}
// generate lesser (344 / 8 = 43) new output per second by averaging
fft256_1.averageTogether(8);
pinMode(pinButton, INPUT_PULLUP);
currentGear = 9;
Serial.println("setup OK");
delay(1000);
}
void loop() {
// read the pot position and set the CPU clock
int gear = (int)((float)analogRead(pinPot) / 102.4f); // is between 0~9
if (currentGear != gear) {
// change the CPU clock
uint32_t speed = minSpeed + gear * 50000000;
//if (gear == 0) speed = 151200000;
set_arm_clock(speed);
currentGear = gear;
Serial.println(currentGear);
Serial.println(speed);
Serial.println(F_CPU_ACTUAL);
}
// check user input
button.update();
if (button.fallingEdge()) {
playSdWav1.play("SDTEST4s.wav");
delay(10); // wait for library to parse WAV info
}
// check peak
if (peak1.available()) {
digitalWrite(pinGreen, HIGH);
} else {
digitalWrite(pinGreen, LOW);
}
// check FFT
if (fft256_1.available()) {
digitalWrite(pinYellow, HIGH);
} else {
digitalWrite(pinYellow, LOW);
}
// wait for audio processes or a button click
delay(2 * debounceTime);
}