I'm trying to create a program, using Qt (c++), which can record audio from my microphone using QAudioinput and QIODevice. Now, I want to visualize my signal
Any help would be appreciated. Thanks
[Edit1] - copied from your comment (by Spektre)
- I Have only one Buffer for both channel
- I use Qt , the value of channel are interlaced on buffer
this is how I separate values
for ( int i = 0, j = 0; i < countSamples ; ++j) { YVectorRight[j]=Samples[i++]; YVectorLeft[j] =Samples[i++]; }
after I plot YvectorRight and YvectorLeft. I don't see how to trigger only one channel
hehe done this few years back for students during class. I hope you know how oscilloscopes works so here are just the basics:
timebase
fsmpl
is input signal sampling frequency [Hz]Try to use as big as possible
(44100,48000, ???)
so the max frequency detected is thenfsmpl/2
this gives you the top of your timebase axis. The low limit is given by your buffer lengthdraw
Create function that will render your sampling buffer from specified start address (inside buffer) with:
This can be done by modification of start address or by just X-offsetting the curve
Level
Create function which will emulate Level functionality. So search buffer from start address and stop if amplitude cross Level. You can have more modes but these are basics you should implement:
( < lvl ) -> ( > lvl )
( > lvl ) -> ( < lvl )
There are many other possibilities for level like glitch,relative edge,...
Preview
You can put all this together for example like this: you have
start address
variable so sample data to some buffer continuously and on timer calllevel
withstart address
(and update it). Then call draw with newstart address
and addtimebase period
tostart address
(of course in term of your samples)multichannel
I use Line IN so I have stereo input (A,B = left,right) therefore I can add some other stuff like:
A,B
,none)x
axis isA
,y
axis isB
this creates famous Chebyshev images which are good for dependent sinusoidal signals. Usually forming circles,ellipses,distorted loops ...miscel stuff
You can add filters for channels emulating capacitance or grounding of input and much more
GUI
You need many settings I prefer analog knobs instead of buttons/scrollbars/sliders just like on real Oscilloscope
Here are some screenshots of my oscilloscope:
Here is screenshot of my generator:
And finally after adding some FFT also Spectrum Analyser
PS.
Btw. I have these three apps as linkable C++ subwindow classes (Borland)
Hope it helps if you need help with anything just comment me
[Edit1] trigger
You trigger all channels at once but the trigger condition is checked usually just from one Now the implementation is simple for example let the trigger condition be the A(left) channel rise above level so:
first make continuous playback with no trigger you wrote it is like this:
Add trigger
To add trigger condition you just find sample that meets it and start drawing from it so you change it to something like this
view_samples
is the viewed/processed size of data (for one or more screens) it should be few times less then the(countSamples>>1)