Audio board lo-fi options

Status
Not open for further replies.

JotaEfe13

Well-known member
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.
 
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.
 
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 !
 
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-detail/en/diodes-incorporated/FK1330001Z/FK1330001ZCT-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?
 
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?
 
fwiw, incidentally the SP1200 also came up here the other day: https://www.muffwiggler.com/forum/viewtopic.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".
 
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.
 
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.
 
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.

iNWtnZt.png


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.
 
Hi,

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,

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:

write(CHIP_CLK_CTRL, 0x0004); // 44.1 kHz, 256*Fs --> 44100 Hz (default)
write(CHIP_CLK_CTRL, 0x0014); // 44.1 kHz, 256*Fs, RATE_MODE 1/2 of the SYS_FS rate --> 22050 Hz
write(CHIP_CLK_CTRL, 0x0024); // 44.1 kHz, 256*Fs, RATE_MODE 1/4 of the SYS_FS rate --> 11025 Hz
write(CHIP_CLK_CTRL, 0x0034); // 44.1 kHz, 256*Fs, RATE_MODE 1/6 of the SYS_FS rate --> 7350 Hz
write(CHIP_CLK_CTRL, 0x000C); // 96 kHz, 256*Fs --> 96000 Hz
write(CHIP_CLK_CTRL, 0x003C); // 96 kHz, 256*Fs, RATE_MODE 1/6 of the SYS_FS rate --> 19000 Hz
write(CHIP_CLK_CTRL, 0x0018); // 48 kHz, 256*Fs, RATE_MODE 1/2 of the SYS_FS rate --> 24000 Hz

BTW, cool project that batdetector.
 
Hi

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.

regards
Cor
 
Status
Not open for further replies.
Back
Top