Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Question regarding effect of changing sampling rate and block sample size on queues

  1. #1

    Question regarding effect of changing sampling rate and block sample size on queues


    I am looking to record a short duration of sound and analyze the recorded queue for a particular frequency tone, and when it peaks in my recording. I am triggering the recording at the same time a tone is played from another teensy, and by processing the recorded queue I hope to determine the time elapsed based on which packet crosses the threshold.
    From documentation I can see that about 53 packets in the queue give ~150ms of audio. So can conclude each 128 16bit packet is about ~3ms.

    If I were to change AUDIO_BLOCK_SAMPLES to say 64, and also change the audio sampling rate to say 176khz, how would that affect the queue object and how many seconds of data each packet would contain. I'd like to estimate this if possible. The smaller the discretization the better for my use.

    Also I think for copying over the queue contents to a buffer, the size of each packet would change if the Audio_block_samples are changed. Can someone confirm if my deduction is correct?
    memcpy(buffer_1+i*256, queue_r.readBuffer(),256);


  2. #2
    Senior Member
    Join Date
    Jul 2020
    packet_time = samples_per_packet / sample_frequency (by definition, not an estimate).

    So default is 128 / 44100 ~= 2.9ms
    with your numbers, 64 / 176000 ~= 0.307ms

    Yes you need to use the size in bytes of the sample buffer to memcpy. For 16 bit samples its 2 bytes per sample, so 64 16-bits samples are 128 bytes.

  3. #3
    That make sense, thanks Mark!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts