Although the sampling rate, as a factor involved in implementation of signals in the actual digital system, is outside the scope of AUX (the language), we cannot completely ignore it when using AUXLAB--the actual software. As you try to play sounds through your computer sound card, you will have to decide the sampling rate that you want to play the sound with. By default, AUXLAB runs on a sampling rate of 22050 Hz, but this can be adjusted as needed (you can access the option for the sampling rate from the system menu from the "variable show" window). Although we have said that AUX is all about "conceptual representation" and not about implementation, in the practical sense, sometimes you have to be mindful of the sampling rate and check whether you have set it appropriately. For example, you cannot have any frequency components exceeding the Nyquist frequency. In other words, if you need a 20000-Hz tone, you need to have the sampling rate over 40000 Hz.
- Note on filtering and the sampling rate
If you bring your own filter coefficients and use the filt
function, those coefficients are only valid for the sampling rate where they were created. If you change the sampling rate, you have to convert them or obtain them afresh. If you use one of those "common" filters--lpf, hpf, bpf,
, you do not have to worry about having to provide different coefficients for different sampling rates. Still, remember that any cut-off frequencies cannot exceed the Nyquist frequency. Even when they are below Nyquist, if they approach it, the filter may become unstable, so beware. Well, you cannot completely get away from considering some technical details in signal processing, if you were to push the limit.
- When opening a .wav file with the wave function
If you open a .wav file with a sampling rate different from that in the AUXLAB environment, either the newly retrieved signal has to convert its sampling rate or AUXLAB has to adjust its sampling rate according to the new signal. Here's how it works currently: if there are already variables in the AUXLAB workspace, the new signal is resampled to match with the AUXLAB environment. If there are no variables (if you call the function first time you launch the application or right after you have cleared all variables), AUXLAB adjusts its sampling rate according to the sampling of the .wav file. This means that the sampling rate might change without you realizing it, which maybe OK or not, depending on the circumstances. If you need to keep the sampling rate of AUXLAB at a certain value and don't mind resampling the retrieved .wav files as you open them, you can do so by the function setfs