Forum Rule: Always post complete source code & details to reproduce any issue!
-
Audio lib ..Oscillator object can it be run above 22k ?
can the oscillator object in the audio lib run past 22 kHz ..?? Or be pushed beyond 22 kHz?
-
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;
}
-
Thankyou very much for sleuthing that out ..greatly appreciated ..!!!
-
Senior Member
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.
-
Senior Member
Hi,
In the batdetector project ( https://forum.pjrc.com/threads/38988-Bat-detector ) we use the oscillator function at very high samplerates (up to 352k) without any problems. In the heterodyne mode we mix this oscillator with incoming sound to detune. I have had no issues at all with this.
regards
Cor
-
Senior Member
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-sig...ultiplication/
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 by DD4WH; 09-19-2020 at 01:12 PM.
-
No problem Paul ..if I notice anything I'll post up ..Corbet, thanks for the info I want to heteodyne down as well ..cheers
-
Yes the goal is fs/4 ..thanks for the code snippit
-
Wow .. nice ..I was going to run at fs/4 ..this will help alot ..thank You very much !
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
-
Forum Rules