In perls Chart::gnuplot (or the interactive terminal version of gnuplot as a second best), when applying smoothing is there a way of varying the 'tightness' of changes of direction of the plot?
I hope this is not a bad explanation of what I am getting at. Im not highly mathematical and I don't really understand the mathematical basis of smoothing graph curves. I am just trying to get some graphs of network traffic originating in netflow packets captured from cisco devices. I can see that rrdtool makes nice graphs which look natural and intuitive to the eye but I have not been able to replicate the look in Chart::gnuplot (I don't want to use rrdtool because the application does not really fit the tool - it would be a hack - I just want to spit the PNG files out of the current perl application which collects and sorts the data from various cisco devices around the network).
If I use csplines with a dataset of 50 x coords I just get a graph of jagged edges. With 5 x coords I get a nice smooth graph but its 'oversmoothed' - not what I need. If I were to try to describe it I would say I am after something which looks more like a histogram (or to be more precise in gnuplot terms I mean style=boxes) but with a degree of 'flow' to it. A good example would be http://oss.oetiker.ch/rrdtool/gallery/btdmd8.png.
If anyone can comment thanks in advance for your time.
Related
I am a developer and not very familiar with MATLAB unless its about basics. Lately, I read some articles about Kemar HRTF database and i would like to test it under MATLAB to get a clear idea what it does, then try to implement an android audio 3D application using hrtf.
I looked everywhere for a good documentation but i couldnt find any (example)..
I know i should convolve my input stereo signal with the hrtf, but can anyone explain to me what is the meaning of all the files in the database, and which one to use? I ll be grateful.
HRTFs are direction dependant. The database is in polar coordinates, the folders are elevation angle and the files contain the impulse response for a respective azimuth under that elevation angle (for left and right channels respectively).
You need to use the impulse responses that correspond to the direction that the audio is supposed to come from and fold your audio data with that (or use the FFT on both, multiplicate them, then use the IFFT).
Note that that database is very old. It shouldn't be too hard to get data with better angular resolution (10° resolution in elevation is quite bad).
See http://sofacoustics.org/
http://sofacoustics.org/data/database/ari%20%28artificial%29/ in particular. The data from ARI usually has a resolution of 2.5°.
I have a set of 3D points which numbers up around 1 million points. I am looking to visualise these with matlab.
I have tried the following functions:
plot3
scatter3
But they are both very sluggish. Is there a more efficient way to visualise this level of points in matlab? Maybe a way to mesh the points?
If not can anyone suggest a plug-in or even a different program for visualising 3D points?
You're going to run into efficiency issues no matter what plugin/program you use if you want all million+ points to show up in a plot. My suggestion would be to downsample. Use the plot3 or scatter3 function on every other point, or every nth point, until you get a figure that is not sluggish. As long as the variance in your data isn't astronomical, downsampling a little bit shouldn't affect the overall distribution of points (given that you have a million+ points). And any software that is able to display that much data without being sluggish is most likely downsampling/binning or using some interpolation technique to do so (so you might as well have control over it).
fscatter3 from the file exchange, does what you like.
Is there a specific reason to actually have it display that many points?
I Googled around a bit and found some people who have had similar issues (someone suggested Avizo as an alternate program but I've never used it):
http://www.mathworks.com/matlabcentral/newsreader/view_thread/308948
mathworks.com/matlabcentral/newsreader/view_thread/134022 (not clickable because I don't have enough rep to post more than two links)
An alternate solution would be to generate a histogram if you're more interested in the density of the data:
http://blogs.mathworks.com/videos/2010/01/22/advanced-making-a-2d-or-3d-histogram-to-visualize-data-density/
I you know beforehand roughly the coordinates of the feature you are looking for, try passing the cloud through a simple pass-through-filter, which essentially crops your point cloud. I.e. if you know that the feature is at a x-coordinate > 5, remove all points with x-coordinate < 5.
This filter could for the first coordinated be realized as
data = data(data(1,:) > 5,:);
Provided that your 3d data is stored in an n by 3 matrix.
This, together with downsampling, could help you out. If you still find the performance lagging, consider using something like the PCD viewer in PointCloudLibrary, check half way down the page at
http://pointclouds.org/documentation/overview/visualization.php
It is a stand alone app you could launch from matlab. I find it's performance far better than the sluggish matlab plotting tools.
For anyone who is interested I ended up finding a Point cloud visualiser called Cloud Compare. It is extremely fast and allows selection and segmentation as well as filtering on point clouds.
i need to smooth better this kind of plot, I've already used a moving average (10 points) to get this plot but it's not yet perfect. I want to remove all these little peaks dued by noise, I need to consider only the bigger ones because I'm counting the num of beats from a sensor.
(ie.: in the first 30 seconds I should have just one peak instead of several successive little peaks)
I thought to use a cubic spline but isn't simple to implement in C and it's going to take almost 1-2 weeks of work.
Is there a simpler method / algorithm to use for this achievement? I'm working on this project for iOS (iPhone) environment.
a busy cat http://img15.imageshack.us/img15/1929/schermata022455973alle1o.png
The answer to your question depends a lot on the underlying data. Is the jaggedness of the data really 'noise' or is it really jagged data.
Strategies you could try:
windowing the data and take the median/mean in each window -- so each window is 50 (from your x axis)
sample the data
Nonlinear least squares curve fit (you'd probably have to use a C++ library for that, here is an open source version you could port http://www.ics.forth.gr/~lourakis/levmar/)
some sort of naive bezier smoothing should be pretty easy.
All of these methods have ramifications and none are without problems. Good luck.
I'm trying to write a simple tuner (no, not to make yet another tuner app), and am looking at the AurioTouch sample source (has anyone tried to comment this code??).
My worry is that aurioTouch doesn't seem to actually work very well when looking at the frequency domain graph. I play a single note on an instrument and I don't see a nicely ordered, small, set of frequencies with one string peak at the appropriate frequency of the note.
Has anyone used aurioTouch enough to know whether the underlying code is functional or whether it is just a crude sample?
Other options I have are to use FFTW or KISS FFT. Anyone have any experience with those?
Thanks.
You're expecting the wrong thing!!
Not the library's fault
Whether the library produces it properly or not, you're looking for a pattern that rarely actually exists in real-life sounds. Only a perfect sine wave, electronically generated, will cause an even partway discrete appearing 'spike' in the freq. graph. If you don't believe it try firing up a 'spectrum analyzer' visualization in winamp or media player. It's not so much the PC's fault.
Real sound waves are complicated animals
Picture a sawtooth or sqaure wave in your mind's eye. those sharp turnaround - corners or points on the wave, look like tons of higher harmonics to the FFT or even a real fourier. And if you've ever seen a real 'sqaure wave/sawtooth' on a scope, or even a 'sine wave' produced by an instrument that is supposed to produce a sinewave, take a look at all the sharp nooks and crannies in just ONE note (if you don't have a scope just zoom way in on the wave in audacity - the more you zoom, the higher notes you're looking at). Yep, those deviations all count as frequencies.
It's hard to tell the difference between one note and a whole orchestra sometimes in a spectrum analysis.
But I hear single notes!
So how does the ear do it? It considers the entire waveform. Then your lower brain lies to your upper brain about what the input is: one note, not a mess of overtones.
You can't do it as fully, but you can approximate it via 'training.'
Approximation: building some smarts
PLAY the note on the instrument and 'save' the frequency graph. Do this for notes in several frequency ranges, or better yet all notes.
Then interpolate the notes to fill in gaps (by 1/2 or 1/4 steps) by multiplying the saved graphs for that instrument by 2^(1/12) (or 1/24 for 1/4 steps, etc).
Figure out how to store them in a quickly-searchable data structure like a BST or trie. Only it would have to return a 'how close is this' score. It would have to identify the match via proportions of frequencies as well, in case it came in different volumes.
Using the smarts
Next time you're looking for a note from that instrument, just take the 'heard' freq graph and find it in that data structure. You can record several instruments that make different waveforms and search for them too. If there are background sounds or multiple notes, take the closest match. Then if you want to identify other notes, 'subtract' the found frequency pattern from the sampled one, and rinse, lather repeat.
It won't work by your voice...
If you ever tried to tune yourself by singing into a guitar tuner, you'll know that tuners arent that clever. Of course some instruments (voice esp) really float around the pitch and generate an ever-evolving waveform (even without somebody singing).
What are you trying to accomplish?
You would not have to totally get this fancy for a 'simple' tuner app, but if you're not making just another tuner app them I'm guessing you actually want to identify notes (e.g., maybe you want to autogenerate midi files from songs on the radio ;-)
Good luck. I hope you find a library that does all this junk instead of having to roll your own.
Edit 2017
Note this webpage: http://www.feilding.net/sfuad/musi3012-01/html/lectures/015_instruments_II.htm
Well down the page, there are spectrum analyses of various organ pipes. There are many, many overtones. These are possible to detect - with enough work - if you 'train' your app with them first (just like telling a kid, 'this is what a clarinet sounds like...')
aurioTouch looks weird because the frequency axis is on a linear scale. It's very difficult to interpret FFT output when the x-axis is anything other than a logarithmic scale (traditionally log2).
If you can't use aurioTouch's integer-FFT, check out my library:
http://github.com/alexbw/iPhoneFFT
It uses double-precision, has support for multiple window types, and implements Welch's method (which should give you more stable spectra when viewed over time).
#zaph, the FFT does compute a true Discrete Fourier Transform. It is simply an efficient algorithm that takes advantage of the bit-wise representation of digital signals.
FFTs use frequency bins and the bin frequency width is based on the FFT parameters. To find a frequency you will need to record it sampled at a rate at least twice the highest frequency present in the sample. Then find the time between the cycles. If it is not a pure frequency this will of course be harder.
I am using Ooura FFT to compute the FFT of acceleromter data. I do not always obtain the correct spectrum. For some reason, Ooura FFT produces completely wrong results with spectral magnitudes of the order 10^200 across all frequencies.
In my Winforms application I have a small chart. Nothing fancy just a bunch of x/y points I connect with lines.
It would be nice to draw a curve instead of a lines to connect these points. But since mathematics was never my strong side I have no idea how to do that.
Any kind of sample or advice would be helpful.
This is very simple - no need for any math - just use Graphics.DrawCurve instead of DrawPolygon/DrawLine (see the very good help on this function).
Apologies for the thread resurrection, but I had to reply to this one:
Be clear in your mind what you want to achieve. I don't know the details of your project, but the methods being suggested are not appropriate for many applications. The correct solution depends on whether you intend the curves you're drawing to simply look nice, or to represent meaningful data. For the former, drawing a bezier curve is fine, but they are not mathematically meaningful and if you're trying to draw a graph to be interpreted with scientific rigour, they will mislead the user. For many applications what you'd want is a best-fit line. These have clear functional form, for example, a degree-2 polynomial (otherwise known as a parabola), a logarithmic curve, or a moving-average. All these are present in Excel and all have specific applications and are emphatically the wrong choice for anything outside their specific remit. The topic of statistical analysis of data is probably beyond the scope of a StackOverflow post - but to start with, look up 'linear regression', what you're describing is comprehensively dealt with by this area of mathematics.