| Products > Test Equipment |
| Question: Cheap pure sine wave genertor 1khz? |
| << < (6/19) > >> |
| hamster_nz:
I've had others recommend using the PC audio too, so I though I'ld give it try to see. I just wrote a quick hack to split 1kHz out of my Intel NUCs onboard audio, with the volume set to just below where bad harmonic distortion sets in (about 0.5V pk-pk) Spectrum is below. If anybody has any good cheap sound dongle recommendations, I'm all ears... Contents of Makefile: --- Code: ---all : sin ./sin | aplay -r 48000 -c 2 -f S16_BE sin : sin.c gcc -o sin sin.c -Wall -pedantic -O4 -lm --- End code --- Contents of "sin.c": --- Code: ---#include <stdio.h> #include <stdint.h> #include <math.h> int main(int argc, char *argv[]) { int i = 0; while(1) { double angle = i * 2 *M_PI / 48.0; double s = sin(angle); uint32_t u_sample = (s+1.0) * 16384; int32_t i_sample = u_sample - 16384; putchar((i_sample>>8) & 0xFF); putchar((i_sample>>0) & 0xFF); putchar((i_sample>>8) & 0xFF); putchar((i_sample>>0) & 0xFF); i = (i == 47 ? 0 : i+1) ; } } --- End code --- |
| andy3055:
I use this: https://www.szynalski.com/tone-generator/ |
| innkeeper:
do you know the thd+n of the output signal? |
| Marco:
Vojtěch Janásek has a circuit described on his website, but maybe more importantly he also has a relatively simple circuit to knock down the fundamental frequency so you can measure the distortion with lower quality equipment. |
| RoGeorge:
--- Quote from: hamster_nz on January 11, 2020, 05:06:21 am ---I've had others recommend using the PC audio too, so I though I'ld give it try to see. I just wrote a quick hack to split 1kHz out of my Intel NUCs onboard audio, with the volume set to just below where bad harmonic distortion sets in (about 0.5V pk-pk) Spectrum is below. If anybody has any good cheap sound dongle recommendations, I'm all ears... Contents of Makefile: --- Code: ---all : sin ./sin | aplay -r 48000 -c 2 -f S16_BE sin : sin.c gcc -o sin sin.c -Wall -pedantic -O4 -lm --- End code --- Contents of "sin.c": --- Code: ---#include <stdio.h> #include <stdint.h> #include <math.h> int main(int argc, char *argv[]) { int i = 0; while(1) { double angle = i * 2 *M_PI / 48.0; double s = sin(angle); uint32_t u_sample = (s+1.0) * 16384; int32_t i_sample = u_sample - 16384; putchar((i_sample>>8) & 0xFF); putchar((i_sample>>0) & 0xFF); putchar((i_sample>>8) & 0xFF); putchar((i_sample>>0) & 0xFF); i = (i == 47 ? 0 : i+1) ; } } --- End code --- --- End quote --- Neat! :-+ I didn't know there is a tool (aplay) that can take numbers from a pipe and throw them at the sound card. Questions: - is "i_sample>>0" there for readability only, and optimized out during compilation, or is it for something else? - where from is the FFT screen capture, and why does it show a -14 dBV DC component? - did you used some loopback between play and rec inside the audiocard, or physical cables? |
| Navigation |
| Message Index |
| Next page |
| Previous page |