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

Thread: Audio board lo-fi options

  1. #1
    Junior Member JotaEfe13's Avatar
    Join Date
    Jan 2019
    Posts
    10

    Audio board lo-fi options

    Hi.
    I would like to know if it is possible to adjust the following parameters in the audio board in order to record lo-fi audio:
    1 - Decrease sampling rate.
    2 - Decrease bit depth.
    3 - Disable anti-aliasing filter.

    I know that one option would be just no using the audio board, at least to achive number 2 and number 3, but it implies much more work with the connections and losing audio storage capabilities.

    Thak you for your help.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    Maybe you could explain *why* you wish to do these things? We can help you much better if we actually understand your needs.

    If the only reason is to reduce the data size for storage, a much better approach is to add a low-pass filter between the I2S input & queue object which lets you access the samples. Then when you get the data, discard some of the samples. If you want fewer bits, just discard the lower bits too.

    If you have some other goal than simply reducing the data size, I can't understand if you don't give some context.

  3. #3
    Junior Member JotaEfe13's Avatar
    Join Date
    Jan 2019
    Posts
    10
    Sorry. You are right, I should have been more specific in my question.

    The purpose is to replicate (to a certain extent) the sound of old sampling machines. For example, the SP 1200 (in my avatar), became the Holy Grail in old school Hip Hop sampling due to that specific flavour in its sound. It was released in the late 80's and had 26.04 kHz sampling rate and 12 bits depth. To cut costs they decided not to put any anti-aliasing filter too. In the end, what was expected to be a downside became later the stamp of its sound. The artifacts produced for this technical characteristics where amplified for a new technique created to get over the limitations of its sampling time (10 sec). It consisted in sampling 33rpm records from a turntable at a 45rpm speed and later lower the pitch to recover the original speed of the sample.

    I know it can look kind of silly trying to achive "bad" sound, but there are many people fond of the sound of those machines, as it is really remarcable.

  4. #4
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,531
    1) yes - with a little trick
    2) yes - with a queue that discards the lower bits
    3) i think yes, but...hm, not sure, please read the SGTL5000 Datasheet !

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    You're also going to need this info, to understand how to hack the audio library.

    https://www.pjrc.com/teensy/td_libs_...ewObjects.html

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,734
    On the sample rate, you have 2 paths.

    1: Stay with I2S master mode (which Teensy controls the audio sample rate), and try to configure MCLK for 6.666 MHz (sample rate * 256).

    2: Use I2S slave mode (where the codec chip controls sample rate). You would disconnect MCLK from Teensy and drive it from some other oscillator. But as nearly as I can tell from a quick digikey search, there aren't 6.666 MHz oscillators readily available. But you can but 13.3333 MHz ones. For example:

    https://www.digikey.com/product-deta...K1330001ZCT-ND

    Maybe if you pair this with a divide-by-2 circuit, you could get the proper MCLK frequency. The SGTL5000 divides MCLK by 256 to gets its sample frequency. You'll also need to change the I2C code that initializes SGTL5000, because it configure for slave mode where Teensy provides BCLK and LRCLK. You'll want it to create those clocks. Then just use the I2S slave object to receive them (at least that part is done).


    Reducing bit depth is simple - just discard the bits you don't want after you've got the data. Easy peasy!


    But as far as disabling the anti-aliasing filter, I'm afraid I have no ideas there. As far as I know, it's fundamentally part of the SGTL5000 and can't be configured in any way. Then again, I've never really tried to fiddle with it... maybe there's something buried in the datasheet I've missed?

  7. #7
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,531

  8. #8
    Senior Member
    Join Date
    Feb 2017
    Posts
    272
    Just a thought (haven't tried it), but if you wanted to exactly halve the effective sampling rate (down to ~22.05 KS/s) then you'd discard half of the samples and then repeat each of the remaining samples once. So now the sound is effective sampled at 22.05 KS/s but the Audio Library would be operating at its normal 44.1 KS/s.

    So, if we were to represent consecutive samples by consecutive letters of the alphabet, you'd go from this:
    A B C D E F G H I J K L M N O P

    to this:
    A A C C E E G G I I K K M M O O

    Perhaps you could do something similar with a non-integral ratio?

  9. #9
    Senior Member
    Join Date
    Feb 2013
    Posts
    559
    fwiw, incidentally the SP1200 also came up here the other day: https://www.muffwiggler.com/forum/vi....php?p=2990006

    ... the gist being: the SP12/SP1200 should be fairly easy to emulate of sorts using a modern MCU + codec ("fixed" sample rate), or teensy + audio board for that matter, unlike most other samplers from those days (which were based on other architectures). ie, as gfvalvo notes, perhaps think of it more as an "effect".

  10. #10
    Junior Member houtson's Avatar
    Join Date
    Aug 2015
    Location
    Scotland
    Posts
    15
    The current BitCrusher effect in the Audio library has a sample rate reduction effect that works the way that @gfvalvo suggest which won't get you exactly to 26.04 kHz but may be close enough atleast to get you started.

    The standard BitCrusher effect also has bit reduction and is a good example of a simple library object if you are looking hack your own.

    Don't know about the anti-aliasing filter in the SGTL5000 - I think it is before the sample stage (?) which will be running at a higher rate that your simulated sample rate if you use the effect in the library - I'm sure you'll get aliasing effects - whether they'll sound like the SP1200 I don't know.

  11. #11
    Junior Member JotaEfe13's Avatar
    Join Date
    Jan 2019
    Posts
    10
    Thank you all for your replies and advice. They are very helpful.

    I have been reading the datasheet and it doesn't seem to be any easy way to disable the anti-aliasing filter, but I'll continue with the research. Of course, if I make any finding or I am able to hack the audio library succesfully I'll share it here.

  12. #12
    Junior Member JotaEfe13's Avatar
    Join Date
    Jan 2019
    Posts
    10
    Hi. I have been investigating about the sampling rate in the audio board and I found the following info in the data sheet about the options of the CHIP_CLK_CTRL:

    RATE_MODE: Sets the sample rate mode. MCLK_FREQ is still specified relative to the rate in SYS_FS
    0x0 = SYS_FS specifies the rate
    0x1 = Rate is 1/2 of the SYS_FS rate
    0x2 = Rate is 1/4 of the SYS_FS rate
    0x3 = Rate is 1/6 of the SYS_FS rate

    SYS_FS: Sets the internal system sample rate
    0x0 = 32 kHz
    0x1 = 44.1 kHz
    0x2 = 48 kHz
    0x3 = 96 kHz

    MCLK_FREQ: Identifies incoming SYS_MCLK frequency and if the PLL should be used
    0x0 = 256*Fs
    0x1 = 384*Fs
    0x2 = 512*Fs
    0x3 = Use PLL

    I don't fully understand the purpose of the RATE_MODE parameter. As far as I can tell, if you select a rate of 1/2 the SYS_FS rate with a SYS_FS value of 96 kHz it would be like using a sampling rate of 48 kHz, right? So what is the real point of this parameter? For the MCLK_FREQ, I don't understand either how it affects the sampling rate, so I have not touched it.

    I have done some testing sampling two sounds with different configurations. The first sound is a sine wave of 15 kHz and the second sound an extrapolation of a song. These are the resoults of the mono files imported as 44.1 kHz files in Audacicy.



    I realized that lowering the sampling rate I don't need to disable the anti-aliasing filter to obtain artifacts. I assume that it's beacuase lowring the sampling rate, lowers the Nyquist frequency too, while the anti-aliasing filter stays in the same place.
    Let's say the anti-aliasing filter is set at 22kHz. For a sampling rate of 22kHz the Nyquist frecuency is 11kHz. So all the frequencies between 11kHz and 22kHz are causing the artifacts.

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
  •