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

Thread: Audio board lo-fi options

  1. #1

    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,209
    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
    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,244
    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,209
    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,209
    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,244

  8. #8
    Senior Member
    Join Date
    Feb 2017
    Posts
    247
    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
    536
    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
    12
    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
    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.

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
  •