If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

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.

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.

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.

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:

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?

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.

... 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".

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.

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.

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

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.

Just by chance I see you have been testing different setups to change the samplerate, have you done any further work on this ? One of odd things your spectrum graphs show is that with a SR of 44.1Khz (default for SGTL5000 on teensy) and 256Fs (also default) the spectrum for the 15Khz signal is rather "full" with many other signals. Did you use the same signalstrength for the 96Khz&256Fs ?

Just by chance I see you have been testing different setups to change the samplerate, have you done any further work on this ? One of odd things your spectrum graphs show is that with a SR of 44.1Khz (default for SGTL5000 on teensy) and 256Fs (also default) the spectrum for the 15Khz signal is rather "full" with many other signals. Did you use the same signalstrength for the 96Khz&256Fs ?

regards
Cor

Hi. I haven't done further research on this as I have switched to Frank B's suggested AdioTiming library as method to change sample rate.
I can't remember now if I realiced about what you comment on the 44.1Khz - 256Fs spectrum. I guess it was due to some disstorsion in the signal, as sometimes I get unwanted noise in my recordings.
As far as I can remember I used the same signalstrength for all tests.

I have tried to replicate the test again, but now I am getting a lot of noise when I change the chip parameters. If I have time to continue working on it I'll post here any interesting output I may get.
One thing I am still not sure about is whether the SGTL5000 has an anti-aliasing filter or not. Neither in the the documentation nor the manufacturer forums there I have found any reference about it. Nevertheless Paul said he could conclude with some tests that the filter is present in the chip. I tried to test it myself, but my results where not conclusive, although my aproach was quite rudimentary, as I don't have a signal generator.

In you or anyone is interested, this are the different values I used in the control_sgtl5000.cpp file:

Thanks for the reply. As I was going through the possibilities for the bat-detector playing so playing CLK_CTRL settings was something I had not tried yet. It was the difference in harmonics between 44.1Khz and 96 Khz in your posting that raised my interest.
For the bat-detector we (edwin and I)are currently testing the effects of changing the settings for REF_CTRL as this seems to affect signal-strength and quality.