core audio how to generate special waveform - core-audio

core audio how to generate wave like this? Generally , the wave is sine , square or sawtooth . But how to generate waveform like this ? Thanks
http://i.stack.imgur.com/3TxqJ.png

As user Bjorn Roche pointed out, this is not a very clear question. If you want that exact sound, just output the samples you see there. If you want something similar, that example looks a bit like an amplitude modulated sinusoid.
Generating sines, saws, squares, etc. is pretty straightforward, but also boring. Synthesizing sounds and waveforms is a large field that includes lots of differing approaches. For getting interesting oscillator outputs, you can use a wavetable. Beyond that, you can use standard components and then filter, modulate, etc.

Related

Reaction-diffusion parallel growing method

I've created many types of reaction-diffusion patterns using different parameters for death and feed rates etc. Working with them on Ready by GollyGang (a simple C++ software that can grow the patterns based on parameters and code) However, they all end up in curly, combined, maze-like forms, or dots etc. Like this:
What I want to achieve though is more like parallel, straight lines that occasionaly combine looking like veins or growing branches; see the image below:
I've searched for any formula for this but couldn't find any. What parameters should I play with?
For the Gray-Scott reaction-diffusion system, have a look near k=0.0625, F=0.045:
On a sphere it looks like this:
I don't know how they've done the nice spiral though. Perhaps painting into the image is enough to nudge it along. Or you might need to draw an initial pattern. Or perhaps you have to apply a constant bias to the direction of the lines.
Ready: https://github.com/GollyGang/ready
Gray-Scott parameter map: http://mrob.com/pub/comp/xmorphia/
Link to the Nervous System lampshade shown in the question: http://n-e-r-v-o-u-s.com/shop/product.php?code=66&search=lighting

Detecting wind noise [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I want to develop an app for detecting wind according the audio stream.
I need some expert thoughts here, just to give me guide lines or some links, I know this is not easy task but I am planning to put a lot of effort here.
My plan is to detect some common patterns in the stream, and if the values are close to this common patterns of the wind noise I will notify that match is found, if the values are closer to the known pattern great, I can be sure that the wind is detected, if the values doesn't match with the patterns then I guess there is no so much wind....
That is my plan at first, but I need to learn how this things are done. Is there some open project already doing this ? Or is there someone who is doing research on this topics ?
The reason I write on this forum is because I do not know how to google it, the things I found was not I was looking for. I really do not know how to start developing this kind of algorithm.
EDIT 1 :
I tried to record a wind, and when I open the saved audio file for me it was just a bunch of numbers :). I do not even see in what format should I save this, is wave good enough ? Should I use something else, or what if I convert the wind noise audio file in mp3 : is this gonna help with parsing ?
Well I got many questions, that is because I do not know from where to read more about this kind of topic. I tag my question with guidlines so I hope someone will help me.
There must be something that is detectable, cause the wind noise is so common, there must be somehow to detect this, we need only someone to give me tips, someone who is familiar with this topic.
I just came across this post I have recently made a library which can detect wind noise in recordings.
I made a model of wind noise and created a database of examples and then trained a Machine Learning algorithm to detect and meter the wind level in a perceptually weighted way.
The C++/C code is here if it is of use to anyone!
The science for your problem is called "pattern classification", especially the subfield of "audio pattern classification". The task is abstracted as classifying a sound recording into two classes (wind and not wind). You seem to have no strong background in signal processing yet, so let me insert one central warning:
Pattern classification is not as easy as it looks at first. Humans excel at pattern classification. Computers don't.
A good first approach is often to compute the correlation of the Fourier transform of your signal and a sample. Don't know how much that will depend on wind speed, however.
You might want to have a look at the bag-of-frames approach, it was used successfully to classify ambient noise.
As #thiton mentioned this is an example of audio pattern classification.
Main characteristics for wind: it's a shaped (band/hp filtered) white noise with small semi-random fluctuations in amplitude and pitch. At least that's how most synthesizers reproduce it and it sounds quite convincing.
You have to check the spectral content and change in the wavefile, so you'll need FFT. Input format doesn't really matter, but obviously raw material (wav) is better.
Once you got that you should detect that it's close to some kind of colored noise and then perhaps extract series of pitch and amplitude and try to use classic pattern classification algorithm for that data set. I think supervised learning could work here.
This is actually a hard problem to solve.
Assuming you have only a single microphone data. The raw data you get when you open an audio file (time-domain signal) has some, but not a lot of information for this kind of processing. You need to go into the frequency domain using FFTs and look at the statistics of the the frequency bins and use that to build a classifier using SVM or Random Forests.
With all due respect to #Karoly-Horvath, I would also not use any recordings that has undergone compression, such as mp3. Audio compression algorithms always distorts the higher frequencies, which as it turns out, is an important feature in detecting wind now. If possible, get the raw PCM data from a mic.
You also need to make sure your recording is sampled at at least 24kHz so you have information of the signal up to 12kHz.
Finally - the wind shape in the frequency domain is not a simple filtered white noise. The characteristics is that it usually has high energy in the low frequencies (a rumbling type of sound) with sheering and flapping sounds in the high frequencies. The high frequency energy is quite transient, so if your FFT size is too big, you will miss this important feature.
If you have 2 microphone data, then this gets a little bit easier. Wind, when recorded, is a local phenomenon. Sure, in recordings, you can hear the rustling of leaves or the sound of chimes caused by the wind. But that is not wind-noise and should not be filtered out.
The actual annoying wind noise you hear in a recording is the air hitting the membrane of your microphone. That effect is a local event - and can be exploited if you have 2 microphones. It can be exploited because the event is local to each individual mic and is not correlated with the other mic. Of course, where the 2 mics are placed in relations to each other is also important. They have to be reasonably close to each other (say, within 8 inches).
A time-domain correlation can then be used to determine the presence of wind noise. (All the other recorded sound are correlated with each other because the mics are fairly close to each other, so a high correlation means no wind, low correlation means wind). If you are going with this approach, your input audio file need not be uncompressed. A reasonable compression algorithm won't affect this.
I hope this overview helps.

Comparing 2 one dimensional signals

I have the following problem: I have 2 signals over time. They are from the same source so they should be the same. I want to check if they really are.
Complications:
they may be measured with different sample rates
the start / end time do not correlate. The measurement does not start at the same time and end at the same time.
there may be an time offset between the two signals.
My thoughts go along Fourier transformation, convolution and statistical methods for comparison. Can someone post me some links where I can find more information on how to handle this?
You can easily correct for the phase by just shifting them so their centers of mass line up. (Or alternatively, in the Fourier domain just multiplying by the inverse of the phase of the first coefficient.)
Similarly, if you want to line up the images given only partial data, you can just cross correlate and take the maximal value (which is again easy to do in the Fourier domain).
That leaves the only tricky part of this process as dealing with the sampling rates. Now if you know a-priori what the sample rates are, (and if they are related by a rational number), you can just use sinc interpolation/downsampling to rescale them to a common sampling rate:
https://ccrma.stanford.edu/~jos/st/Bandlimited_Interpolation_Time_Limited_Signals.html
If you don't know the sampling rate, you may be a bit screwed. Technically, you can try just brute forcing over all the different rescalings of your signal, but doing this tends to be either slow or else give mediocre results.
As a last suggestion, if you just want to match sounds exactly you can try using the cepstrum and verifying that the peaks of the signal are close enough to within some tolerance. This type of analysis is used a lot in sound and speech recognition, with some refinements to make it operate a bit more locally. It tends to work best with frequency modulated data like speech and music:
http://en.wikipedia.org/wiki/Cepstrum
Fourier transformation does sound like the right way.
There is too much mathematical information for me to just start explaining here so if you really wanna know what's going on with that (cause I don't think you can just use FT without understanding it) you should use this reference from MIT OpenCourseWare: http://ocw.mit.edu/courses/mathematics/18-103-fourier-analysis-theory-and-applications-spring-2004/lecture-notes/
Hope it helped.
If you are working with a linux box and the waveforms that need to be processed have already been recorded, you can try to use the file command to display details about the recording. It gives you the sampling rate when it is invoked on a wav file, though I am not sure what format you are recording in.
If the signals are time-shifted with respect to each other, you may try to convolve one with a delta function with increasing delays and then comparing. On MATLAB, conv and all should be good enough.
These are just 'crude' attempts (almost like hacking at the problem). There may be algorithms that are shift-invariant that may do a better job.
Hope that helps.

Perceptual similarity between two audio sequences

I would like to get some sort of distance measure between two pieces of audio. For example, I want to compare the sound of an animal to the sound of a human mimicking that animal, and then return a score of how similar the sounds were.
It seems like a difficult problem. What would be the best way to approach it? I was thinking to extract a couple of features from the audio signals and then do a Euclidian distance or cosine similarity (or something like that) on those features. What kind of features would be easy to extract and useful to determine the perceptual difference between sounds?
(I saw somewhere that Shazam uses hashing, but that's a different problem because there the two pieces of audio being compared are fundamentally the same, but one has more noise. Here, the two pieces of audio are not the same, they are just perceptually similar.)
The process for comparing a set of sounds for similarities is called Content Based Audio Indexing, Retrieval, and Fingerprinting in computer science research.
One method of doing this is to:
Run several bits of signal processing on each audio file to extract features, such as pitch over time, frequency spectrum, autocorrelation, dynamic range, transients, etc.
Put all the features for each audio file into a multi-dimensional array and dump each multi-dimensional array into a database
Use optimization techniques (such as gradient descent) to find the best match for a given audio file in your database of multi-dimensional data.
The trick to making this work well is which features to pick. Doing this automatically and getting good results can be tricky. The guys at Pandora do this really well, and in my opinion they have the best similarity matching around. They encode their vectors by hand though, by having people listen to music and rate them in many different ways. See their Music Genome Project and List of Music Genome Project attributes for more info.
For automatic distance measurements, there are several projects that do stuff like this, including marsysas, MusicBrainz, and EchoNest.
Echonest has one of the simplest APIs I've seen in this space. Very easy to get started.
I'd suggest looking into spectrum analysis. Whilst this isn't as straightforward as you're most likely wanting, I'd expect that decomposing the audio into it's underlying frequencies would provide some very useful data to analyse. Check out this link
Your first step will definitely be taking a Fourier Transform(FT) of the sound waves. If you perform an FT on the data with respect to Frequency over Time1, you'll be able to compare how often certain key frequencies are hit over the course of the noise.
Perhaps you could also subtract one wave from the other, to get a sort of stepwise difference function. Assuming the mock-noise follows the same frequency and pitch trends2 as the original noise, you could calculate the line of best fit to the points of the difference function. Comparing the best fit line against a line of best fit taken of the original sound wave, you could average out a trend line to use as the basis of comparison. Granted, this would be a very loose comparison method.
- 1. hz/ms, perhaps? I'm not familiar with the unit magnitude being worked with here, I generally work in the femto- to nano- range.
- 2. So long as ∀ΔT, ΔPitch/ΔT & ΔFrequency/ΔT are within some tolerance x.
- Edited for formatting, and because I actually forgot to finish writing the full answer.

Generate musical instrument sounds algorithmically

Is it possible to generate a musical instrument's sounds using only algorithms? or can it only be done via pre-recorded sound samples?
Wavetable synthesis (PDF) is the most realistic method of real-instrument synthesis, as it takes samples and alters them slightly (for example adding vibrato, expression etc).
The waveforms generated by most musical instruments (especially wind and brass instruments) are so complex that pure algorithmic synthesis is not yet optimised enough to run on current hardware - even if it were, the technical complexities of writing such an algorithm are huge.
Interesting site here.
It is completely possible - that is one of the things synthesizers do.
It being possible doesn't mean it is simple. Synthesizers are usually expensive, and the amount of algorithms used are complex - the wikipedia page I linked before has links to some of them.
Pre-recorded sounds are simpler and cheaper to use, but they also have their limitations - they sound more "repetitive" for example.
Several years back, Sound on Sound magazine ran an excellent series called "Synth Secrets" which can now be viewed online for free. They give a good introduction to the types of techniques used in hardware synthesizers (both analogue and digital), and includes some articles discussing the difficulties of replicating certain real-world instrument sounds such as plucked and bowed strings, brass, snare drums, acoustic pianos etc.
After several days of hunting, this the best resource I have found: https://ccrma.stanford.edu/~jos/
This is a treasure trove for the subject of synthesising sounds.
STK
For example, this page links to a C example of synthesising a string, also a sound toolkit STK written in C++ for assisting this work.
This is going to keep me quiet for a few weeks while I dig through it.
It certainly is, and there are many approaches. Wolfram recently released WolframTones, which (unsurprisingly, if you know Wolfram) uses cellular automata. A detailed description of how it functions is here.
Karplus Strong Algorithm gives a very good synthesis of a plucked string. It can also be coded in a few lines of C. You create a circular buffer of floats (length proportional to the wavelength ie 1/f), and fill it full of random noise between -1 and 1.
Then you cycle through: each cycle, you replace the value at your current index with the average of the previous two values, and emit this new value.
index = (index+1) % bufSize;
outVal = buf[index] = decay * 0.5 * ( buf[index-1] + buf[index-2] );
The resultant byte stream gives you your sound. Of course, this can be heavily optimised.
To make your soundwave damp to 0.15 of its original strength after one second, you could set decay thus:
#define DECAY_1S =.15
Float32 decay = pow(DECAY_1S, 1.0f / freq);
Note: you need to size the original buffer so that it contains one complete waveform. so if you wish to generate a 441Hz sound, and your sampling rate is 44.1KHz, then you will need to allocate 100 elements in your buffer.
You can think of this as a resonance chamber, whose fundamental frequency is 441Hz, initially energised, with energy dissipating outwards from every point in the ring simultaneously. Magically it seems to organise itself into overtones of a fundamental frequency.
Could anyone post more algorithms? How about an algorithm for a continuous tone?
In addition to the answers provided here, there are also analysis synthesis frameworks that construct mathematical models (often based on capturing the trajectories of sinusoidal or noise components) of an input sound, allowing transformation and resynthesis. A few well-known frameworks are: SMS (available through the CLAM C++ project,) and Loris.
Physical models of instruments also are an option - they model the physical properties of an instrument such as reed stiffness, blowhole aperture, key clicking, and often produce realistic effects by incorporating non-linear effects such as overblowing. STK is one of these frameworks in C++.
These frameworks are generally more heavy then the wavetable synthesis option, but can provide more parameters for manipulation.
Chuck
This PDF details how SMule created Ocarina for the iPhone (I'm sure everyone has seen the advert). they did it by porting Chuck - Strongly-timed, Concurrent, and On-the-fly
Audio Programming Language
This is available for MacOS X, Windows, and Linux.
I've had a lot of success and fun with FM synthesis. It is a computationally light method, and is the source of a huge number of pop synth sounds from the 1980's (being the basis of the ubiquitous Yamaha DX-7).
I do use it for generating sound on the fly rather than using recordings. A simple example of a string synth sound generated on the fly can be had (free download, Win64) from http://philfrei.itch.io/referencenotekeyboard. The organ synth on that same program is a simple additive synthesis algo.
I would have to dig around for some good tutorials on this. I know we discussed it a bunch at java-gaming.org, when I was trying to figure it out, and then when helping nsigma work out a kink in his FM algo. The main thing is to use phase rather than frequency modulation if you want to chain more than a single modulator to a carrier.
Which reminds me! A kind of amazing java-based sound generator to check out, allows the generation of a number of different forms of synthesis, with real time control:
PraxisLIVE

Resources