Latency and Jitter values for Teensy 3.2 DAC and for the Audio Board's i2s

Status
Not open for further replies.
I have fixed it hardcoding (hammering my head against the code)
in the play method of the AudioPlayMemory class I added a simple "length *= 2;" line

Code:
void AudioPlayMemory::play(const unsigned int *data)
{
	uint32_t format;

	playing = 0;
	prior = 0;
	format = *data++;
	next = data;
	beginning = data;
	length = format & 0xFFFFFF;
	length *= 2;
	playing = format >> 24;
}

I don't know anything about pointers, and I didn't understand what I did, but I believe that if I add a generic line "length *= 128/AUDIO_BLOCK_SAMPLES;"
would that be it?

It worked for 64 samples and 32.
But not with 16 samples... It just gave an annoying 2781 Hz + harmonics beep...
but 32 is already good enough for me!
 
Last edited:
It works with an audio block as low as 32 samples.
It gives an annoying beep with the audio block on 16 samples. It only starts after pressing the button that plays the sample
 
And just for the record, the error message on the analyze_fft256 class persists...

Code:
/.../Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Audio/analyze_fft256.cpp:33:13: warning: 'void copy_to_fft_buffer(void*, const void*)' defined but not used [-Wunused-function]
 static void copy_to_fft_buffer(void *destination, const void *source)
             ^
/.../Arduino.app/Contents/Java/hardware/teensy/avr/libraries/Audio/analyze_fft256.cpp:43:13: warning: 'void apply_window_to_fft_buffer(void*, const void*)' defined but not used [-Wunused-function]
 static void apply_window_to_fft_buffer(void *buffer, const void *window)
             ^
 
It works with an audio block as low as 32 samples.
It gives an annoying beep with the audio block on 16 samples. It only starts after pressing the button that plays the sample

Hm, yes, that's possible - perhaps another change in the memcpy - routines for less than 32 samples is needed.
I can look on sunday, not earlier (sorry).
 
Can you post the exact program you used to measure this? Are you sure the square wave object starts with high signal? I don't know but I'm willing to try to reproduce this also if i had a program to test?

Duff, I made another system for measuring latency on teensy! Now instead of having to use a logic analyser you can just use another teensy!

Here are the codes (I'm using teensyduino 1.31 now):

Teensy with audio board (I'm using 3.2)
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveformDc     dc1;            //xy=226,198
AudioOutputI2S           i2s1;           //xy=616,194
AudioConnection          patchCord3(dc1, 0, i2s1, 0);
AudioConnection          patchCord4(dc1, 0, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=77,24
// GUItool: end automatically generated code

int button0 = 0;
int button0Pin = 2;

void setup() {
  pinMode(button0Pin, INPUT);
  AudioMemory(10);
  sgtl5000_1.enable();
  sgtl5000_1.volume(1);
}

void loop() {
  button0 = digitalRead(button0Pin);
  if (button0 == HIGH) {
    dc1.amplitude(1);
    delay(66);
    dc1.amplitude(-1);
  }
}

And here is the code to put in the other Teensy (I'm with another 3.2), I'm calling it the measurer
Code:
#define OUT_PIN 13
#define IN_PIN_SOUND 12
#define IN_PIN_BUTTON 11

void setup() {
  Serial.begin(115200);

  pinMode(OUT_PIN, OUTPUT);
  pinMode(IN_PIN_SOUND, INPUT);
  pinMode(IN_PIN_BUTTON, INPUT);

  attachInterrupt(IN_PIN_BUTTON, isrServiceButton, RISING);
  attachInterrupt(IN_PIN_SOUND, isrServiceSound, RISING);
}

elapsedMillis blinkTime;

unsigned long outputTriggerTime = 0;
unsigned long latencyTime = 0;
unsigned int randomDelay;



void loop() {
    if (blinkTime < 100) {
      digitalWrite(OUT_PIN, HIGH);
    } else if (blinkTime < 200) {
      digitalWrite(OUT_PIN, LOW);
    } else {
      blinkTime = 0; // start blink cycle over again
    }
}

void isrServiceButton()
{
  cli();
  outputTriggerTime = micros();
  sei();
}

void isrServiceSound()
{
  cli();
  latencyTime = micros() - outputTriggerTime;
  Serial.println(latencyTime);
  sei();
}

you just connect GND's and 3v3's of both teensies
pin11 and pin13 of the measurer to pin2 of the teensy with the audio board
pin 12 of the measurer to the L or R pin of the headphone pin (those tiny holes)

you just check the serial data that is coming in from the measurer. 1000 values is good enough but it actually stabilizes around 7000 values... You just copy and paste them in excel, matlab or wherever you want to analyse it...
 
Status
Not open for further replies.
Back
Top