Audio lib ..Oscillator object can it be run above 22k ?

Status
Not open for further replies.
That would be meaningless at 44100 sample rate as +23kHz = -21.4kHz, and unless you are handling complex (ie quadrature) signals
negative and positive frequencies are indistinguishable. So going over 22.05kHz means going below 22.05kHz - above 22.05k is aliased
to below 22.05k

If you change the sampling rate of the library that's another matter, but not every I/O option can handle this readily.

If you look at the code you'll probably find the frequency is constrained to a suitable range for most of the synthesis
classes.
 
Well ..no.. it's not neaningless as I'm sampling at 192k right now... What I'm doing is creating an SDR receiver..The higher sampling frequency gives me a larger spread bandwidth wise to view on the FFT display ....but I wanted to digitally mix the oscillator with the incoming signal to digitally mix it down to a lower intermediate frequency ..
 
Most sdr receivers are running 6k to 11k for their intermediate frequency ...I'd like to run it higher ..around 20k
 
The AudioSynthWaveform class limits frequency to Nyquist, so if the audio sample rate is set higher it will allow higher frequencies,
just checked the code:

Code:
	void frequency(float freq) {
		if (freq < 0.0) {
			freq = 0.0;
		} else if (freq > AUDIO_SAMPLE_RATE_EXACT / 2) {
			freq = AUDIO_SAMPLE_RATE_EXACT / 2;
		}
 
Indeed it should work up to half the sample rate. But the audio library gets relatively little testing at other sample rates. If you do find any bugs where it does something wrong, please mention them here.
 
In the context of Software Defined Radio dealing with analytical (complex) signals, builders often use an IF at exactly samplerate-divided-by-4, ie. in your case 192ksps / 4 = 48kHz

Then you are able to use a frequency translation method with nearly zero processor load:

https://www.embedded.com/digital-si...frequency-translation-without-multiplication/

This is very easy to implement and works nicely (an example code):
Code:
      // this is for +Fs/4 [moves receive frequency to the left in the spectrum display]
      for (unsigned i = 0; i < BUFFER_SIZE * N_BLOCKS; i += 4)
      { // float_buffer_L contains I = real values
        // float_buffer_R contains Q = imaginary values
        // xnew(0) =  xreal(0) + jximag(0)
        // leave as it is!
        // xnew(1) =  - ximag(1) + jxreal(1)
        hh1 = - float_buffer_R[i + 1];
        hh2 =   float_buffer_L[i + 1];
        float_buffer_L[i + 1] = hh1;
        float_buffer_R[i + 1] = hh2;
        // xnew(2) = -xreal(2) - jximag(2)
        hh1 = - float_buffer_L[i + 2];
        hh2 = - float_buffer_R[i + 2];
        float_buffer_L[i + 2] = hh1;
        float_buffer_R[i + 2] = hh2;
        // xnew(3) = + ximag(3) - jxreal(3)
        hh1 =   float_buffer_R[i + 3];
        hh2 = - float_buffer_L[i + 3];
        float_buffer_L[i + 3] = hh1;
        float_buffer_R[i + 3] = hh2;
      }
 
Last edited:
No problem Paul ..if I notice anything I'll post up ..Corbet, thanks for the info I want to heteodyne down as well ..cheers
 
Status
Not open for further replies.
Back
Top