Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 87 of 87

Thread: Teensy 4 SPDIF input + ASRC

  1. #76
    Is the results what you expected?
    I could only test the algorithm with my hardware and until now nobody else posted results of some tests. So there is not much empirical data. I assumed that
    the results are much better than with results of your test with the analog signal.

    Regarding your questions about the resampling algorithm: First I want to mention that I wasn't involved in the developement of the algorithm.
    You are probably aware of that, but I want to mention it in case somebody skims the thread and gets that impression.

    In the introduction of the document, the authors write:
    "The algorithm effectively implements the “analog interpretation” of rate conversion, as discussed in [1], in which a certain lowpass-filter impulse response must be available as a continuous function. Continuity of the impulse response is simulated by linearly interpolating between samples of the impulse response stored in a table."
    In section 3.3 they further desribe the “analog interpretation”. If you stick to this interpretation, then there is no L and M factor. A new sample can be computed at arbitrary times t
    by shifting the sinc filter to t, computation of the interpolation weights by evaluating the sinc-function and computing the linear combination of the input samples.

    If you want to interpret the algorithm in the "standard" way, I can tell you at least what L is: The table with the lowpass-filter contains a densely sampled version of the filter.
    L is the factor by which the lowpass-filter is more densely sampled than the input signal.
    The algorithm first interpolates by a factor L and new samples are computed at arbitrary positions by linear interpolation of the signal.


    At the Teensy implementation a Kaiser-windowed sinc-filter is used as lowpass-filter and the limiting factor is the size of the table that stores the coefficients of the filter.
    L depends on the length of the filter. So I can't tell you a single number, but give you an examples of N:

    Currently the size of the table is 20*1024 + 1 samples (MAX_FILTER_SAMPLES in resampler.h / only one wing of the filter is stored).
    The default resampling parameters are:
    attenuation=100
    minHalfFilterLength=20
    maxHalfFilterLength=80

    Let's say the input frequency is 48kHz.
    The lowpass-filter is designed as described here:
    https://tomroelandts.com/articles/ho...-kaiser-window
    Parameter b is chosen in order to prevent aliasing frequencies below 20kHz.

    This results in a filter length of 77 ( 2*input.getHalfFilterLength() +1).
    N=floor(20*1024/38)=538
    Last edited by alex6679; 11-27-2021 at 01:28 PM.

  2. #77
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by alex6679 View Post
    I could only test the algorithm with my hardware and until now nobody else posted results of some tests. So there is not much empirical data. I assumed that
    the results are much better than with results of your test with the analog signal.
    thanks. here's the results on the analog signal. I think I recorded it with a lower volume than the SPDIF one I showed you in my last post.

    Click image for larger version. 

Name:	linein.jpg 
Views:	17 
Size:	55.4 KB 
ID:	26692

  3. #78
    Thanks for sharing the result.

  4. #79
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by alex6679 View Post
    Thanks for sharing the result.
    You're welcome. As you see, the results seem better for the spdif input. However, if I understand correctly, the Teensy processes 16-bit data which will not show much information on the noise floor below 96dB. As results on the audio input, are nevertheless quite good, I have decided not to use the spdif optical i/o connectors for my AGC/Compressor box. The box is a little too small to accomodate the additional space required by them in comparison to the actual audio jacks. However, I will keep in mind the possibility of using the spdif asrc input for future projects.

  5. #80
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,354
    Quote Originally Posted by Bill Glass View Post
    However, if I understand correctly, the Teensy processes 16-bit data which will not show much information on the noise floor below 96dB.
    The quantization noise is about 98dB below max signal power for 16 bits (for a square wave, or 95dB for a sinusoid).
    This is the noise power, not the noise's PSD (power spectral density, which is per unit frequency), note, which for a bandwidth
    of 20kHz would be 43 dB lower than the total noise power - the units of PSD are W/Hz though often are proxied by
    an amplitude measurement of V/√Hz (since the actual power depends on impedance which is often not known).

    You have to be careful interpreting FFT plots comparing signal peaks to noise floors, since the size of the FFT and
    the window function's noise-bandwidth both affect the scaling of noise PSD relative to signal peak amplitude. By using
    larger and larger FFT sizes you can push the noise floor lower and lower without limit if you don't correct for the FFT
    bin width in Hz.

    There's a thorough treatment of this here:
    https://holometer.fnal.gov/GH_FFT.pdf

  6. #81
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by MarkT View Post
    The quantization noise is about 98dB below max signal power for 16 bits (for a square wave, or 95dB for a sinusoid).
    This is the noise power, not the noise's PSD (power spectral density, which is per unit frequency), note, which for a bandwidth
    of 20kHz would be 43 dB lower than the total noise power - the units of PSD are W/Hz though often are proxied by
    an amplitude measurement of V/√Hz (since the actual power depends on impedance which is often not known).

    You have to be careful interpreting FFT plots comparing signal peaks to noise floors, since the size of the FFT and
    the window function's noise-bandwidth both affect the scaling of noise PSD relative to signal peak amplitude. By using
    larger and larger FFT sizes you can push the noise floor lower and lower without limit if you don't correct for the FFT
    bin width in Hz.

    There's a thorough treatment of this here:
    https://holometer.fnal.gov/GH_FFT.pdf
    OK. I will look at it. However I used the same method for analyzing the recorded samples from the audio and the Async spdif inputs.

  7. #82
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    @MarkT @alex6679

    I haven't yet looked at https://holometer.fnal.gov/GH_FFT.pdf but I also evaluate an audio wav file with a C tool. The tool does not do FFT analysis but rather calculates energy ratios. Total energy divided by remaining energy after passing the audio thru a narrow notch filter tuned to the signal frequency (in this case, 10kHz). For spdif.wav, I obtain 87.7 dB. For linein.wav, I obtain 71.6dB.

  8. #83
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,354
    That's basically measuring the SINAD directly for a sinusoid.

  9. #84
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by alex6679 View Post
    I could only test the algorithm with my hardware and until now nobody else posted results of some tests. So there is not much empirical data. I assumed that
    the results are much better than with results of your test with the analog signal.

    Regarding your questions about the resampling algorithm: First I want to mention that I wasn't involved in the developement of the algorithm.
    You are probably aware of that, but I want to mention it in case somebody skims the thread and gets that impression.

    In the introduction of the document, the authors write:
    "The algorithm effectively implements the “analog interpretation” of rate conversion, as discussed in [1], in which a certain lowpass-filter impulse response must be available as a continuous function. Continuity of the impulse response is simulated by linearly interpolating between samples of the impulse response stored in a table."
    In section 3.3 they further desribe the “analog interpretation”. If you stick to this interpretation, then there is no L and M factor. A new sample can be computed at arbitrary times t
    by shifting the sinc filter to t, computation of the interpolation weights by evaluating the sinc-function and computing the linear combination of the input samples.

    If you want to interpret the algorithm in the "standard" way, I can tell you at least what L is: The table with the lowpass-filter contains a densely sampled version of the filter.
    L is the factor by which the lowpass-filter is more densely sampled than the input signal.
    The algorithm first interpolates by a factor L and new samples are computed at arbitrary positions by linear interpolation of the signal.


    At the Teensy implementation a Kaiser-windowed sinc-filter is used as lowpass-filter and the limiting factor is the size of the table that stores the coefficients of the filter.
    L depends on the length of the filter. So I can't tell you a single number, but give you an examples of N:

    Currently the size of the table is 20*1024 + 1 samples (MAX_FILTER_SAMPLES in resampler.h / only one wing of the filter is stored).
    The default resampling parameters are:
    attenuation=100
    minHalfFilterLength=20
    maxHalfFilterLength=80

    Let's say the input frequency is 48kHz.
    The lowpass-filter is designed as described here:
    https://tomroelandts.com/articles/ho...-kaiser-window
    Parameter b is chosen in order to prevent aliasing frequencies below 20kHz.

    This results in a filter length of 77 ( 2*input.getHalfFilterLength() +1).
    N=floor(20*1024/38)=538

    If I correctly understood your explanations:

    My understanding is:

    AsyncSpdif
    ----------------
    delay_line_length=68 (for half filter length of 34)
    Ncoefs=20481
    983 MACS/sample (600MHZ=>13605MACS/sample@44100Kz) at 100% or 983 for 7.23% actual processor usage)

    However, I imagine there's other stuff going on besides the filtering when the command, double pUsageIn=spdifIn.processorUsage() , is issued.

    And here's what I got via the serial monitor:

    Click image for larger version. 

Name:	ASRCinfo.jpg 
Views:	5 
Size:	67.4 KB 
ID:	26727

  10. #85
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by MarkT View Post
    That's basically measuring the SINAD directly for a sinusoid.
    SINAD ?
    A good or bad method for evaluating the quality of a sample rate converter?

  11. #86
    Senior Member
    Join Date
    Jul 2020
    Posts
    1,354
    That sounds very like the title of a whitepaper from analog devices or similar, let me search:
    Ah, not quite, I think this might be what I was remembering:
    https://www.maximintegrated.com/en/d...als/7/728.html

  12. #87
    Member
    Join Date
    Sep 2021
    Location
    American living in France
    Posts
    76
    Quote Originally Posted by MarkT View Post
    That sounds very like the title of a whitepaper from analog devices or similar, let me search:
    Ah, not quite, I think this might be what I was remembering:
    https://www.maximintegrated.com/en/d...als/7/728.html
    Yes. I found that it's the inverse of the THD+N (90dB is good for Sinad and -90dB for THD+N). I always thought my tool was measuring THD+N but it's really measuring SINAD.

    https://www.ap.com/blog/thd-and-thdn...-not-the-same/

Tags for this Thread

Posting Permissions

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