# Tag Info

19

A lot depends on your specific data. But if the noise is far from voice in frequency domain there is a simple brute-force trick of cutting off/out "bad" frequencies using wavelets. Let's import some sample recording: voice = ExampleData[{"Sound", "Apollo11ReturnSafely"}] WaveletScalogram is great for visualizing voice versus noise features: cwt = ...

18

Edit: this answer is now structured in two sections. The first deals about creating a candidate RNG from audio data. The second demonstrates some testing I performed on this RNG. Creating the RNG Okay, I'll got at it another way then. I recorded 10 seconds of ambient noise on my MacBook Pro internal speakers. I was possibly in the worst conditions for ...

16

Here's a possible starting point for a solution. It splits the sample list into chunks and measures the Norm of the sample Differences in each chunk, and then does the FFT on that data. bpmplot[snd_, bpmmax_: 300] := Module[{samples, minfreq, signal, fft}, samples = snd[[1, 1, 1]]; minfreq = snd[[1, 2]]/Length[samples]; signal = (Norm[Differences[#]]) ...

16

Running Trace[Speak["Hello"]] and Names["*Speak*"] revealed the following possibility: MathLinkCallFrontEnd[CurrentlySpeakingPacket] Using this with a text that is split into a list of shorter strings allows you to interrupt the audio at well-defined points, phrase breaks, say. Here is one way to do it: Clear[interruptibleSpeak]; ...

14

When you use a very low sample rate, the signal is represented with very few samples. If you are using a very stupid resampler that creates 48 kHz data by just repeating samples, you get a wave form like the blue one below: A better resampler would create the red wave form. Now, the difference between these two wave forms looks like this: This is ...

12

In Mathematica it is easy to turn any time series data into sound. Here are the Boston temperatures for a few decades: data = WeatherData["Boston", "MeanTemperature", {{1970}, {2012}, "Day"}]; DateListLogPlot[data, PlotStyle -> PointSize[0], AspectRatio -> 1/5] To turn it into sound and play it in a Mathematica notebook: ListPlay[data[[All, 2]], ...

12

Here is my quick and dirty attempt based on: Cryptographic Key From Webcam Image. I've used an example image as I don't have a webcam on my desktop but you could simply use CurrentImage to grab the webcam image live if you have one. Update using a webcam image from my laptop image = CurrentImage[]; grayscale = ColorConvert[image, "Grayscale"]; imagedata = ...

12

Due to security restrictions some functions such as Import, Uncompress, or OS access functions cannot be used as a part of Demonstrations code, including the Initialization. So a generally great idea by @acl comment about compression will not work on Demonstrations site (but it's really ncie to use otherwise). This is what you get if you try to use ...

11

vid[time_, frame_] := Module[{tag}, Reap[Do[Sow[CurrentImage[], tag]; Pause[frame], {Round[time/frame]}]][[2, 1]]] So, vid[1., 0.001] would return a list of snapshots taken every 0.001 seconds over a second. This opens a dialog that allows you to record sound and returns it as a Sound object SystemDialogInput["RecordSound"];

11

You want this: data = Import["test.wav", "Data"] This imports the raw data of sample values. For example, on a test file of approximately 10 seconds, stereo at 48000 Hz, data is an array of size 2 × 520192 (from which I can deduce that my recording was actually 10.84 seconds). See the documentation for WAF format import/export, as well as this answer on ...

11

Just saying SampleRate -> 10000000 does not mean that the hardware is capable of playing samples at that rate. (Most modern devices can do 192 kHz; but it's likely you're running at 48 kHz.) Mathematica or the OS or the sound driver or the hardware will resample the data to something that is supported. Depending on how well the resampling is implemented, ...

10

What you need is BandpassFilter, which is new in version 9. Assuming your audio is sampled at 22400 Hz, you can do: BandpassFilter[data, {60 π, 180 π}, SampleRate -> 22400] to filter it to between 60-180 Hz.

9

I feel there may be a few issues here. First, you're using FourierDST, the discrete sine transform. I'm not too familiar with this one, but it looks like you shouldn't confuse it with Fourier. Application of FourierDST as follows: ListLinePlot[ FourierDST[Table[Sin[100 t], {t, 0, 10, 0.02}]][[250 ;; 350]], PlotRange -> All] yields: whereas, with ...

9

You can use CurrentImage and set up a ScheduledTask to capture frames at the desired fps. Something like: frames = {}; fps = 30; task = CreateScheduledTask[frames = {CurrentImage[], frames};, 1/fps]; Then start and stop recording with StartScheduledTask[task]; StopScheduledTask[task]; Note that stopping the task won't turn off the camera on a Mac ...

6

You can simply put the results in a list and apply Sound to the list. An example taken from the docs: Sound[{Play[Sin[1000 t (1 + t^2)], {t, 0, .2}], Play[Sin[500 t (1 + t^3)], {t, 0, .5}]}] You can then export this Sound object.

6

This function is still present in version 8, but it is part of the Audio package. For example, <<Audio` ListWaveform[{{1, 1}, {2, 0.5}}, 440, 1] You can find this information by typing ListWaveform into the documentation browser.

6

Here is another possibility based on mouse movements, updated with live histogram, further updated by hashing a combination of the mouse position and AbsoluteTime: DynamicModule[{}, positionlist = {}; list = {}; EventHandler[{Dynamic[ Framed@Graphics[{Red, Line@positionlist, Point@positionlist}, PlotRange -> 2]], ...

6

This example in Documentation exactly answers your question. You just need to specify overlapping time intervals. Lets expand your specific case. Below after every second a new instrument will come in and they will all end at the same time. Sound[{SoundNote["C", {0, 4}, "Oboe"], SoundNote["G", {1, 4}, "SynthVoice"], SoundNote["C5", {2, 4}, ...

6

Here's mine: -first create a scale by dividing an octave to some intervals (12 gives you the usual good temperament): microscale[divisions_Integer, baseFreq_: 260.741] := Module[{interval}, interval = 2 π /divisions; Play[#, {t, 0, .4}] & /@ Table[Sin[(2 π + i) baseFreq t], {i, 0, 2 π, interval}] ]; which you can use like so: ...

6

Read in the wave file (use Import). Then use the Fourier[]function. This breaks it into a sum of complex exponentials. You can turn this into a trigonometric series using Euler's formula. Here's a bit more detail. Reading in the .wav file is easy: q = Import[fullFileName]; Now q has two parts: the data in q[[All,1]] and the sampling rate in q[[1,2]] ...

6

It shouldn't be too hard to do some simple sound processing. Take an example file: data = ExampleData[{"Sound" , "Apollo13Problem"}] Get a short sequence of sample values from near the end of the file: soundsamples = data[[1, 1]][[All, 110000 ;; -2000]]; It looks OK: ListLinePlot[{soundsamples[[1]]}] Play it without modifications: ...

6

In Mathematica, you can read in .wav files using Import. Since the data is then a discrete data sequence, you can't take a real calculus-style derivative, but you can take the derivative numerically, for instance, using functions like Differences and DerivativeFilter (thanks Jens). In fact, the derivative operation is a kind of high-pass filter, which will ...

6

Here's one way to explore aliasing in audio using a "chirp" signal (thus avoiding the problems of real-time sound generation). A chirp is a sinusoid-like signal with frequency that constantly increases. Using the formula from the Wikipedia page, the chirp can be generated using chirp[t_] := Sin[2 Pi (f0 t + (k/2) t^2)]; which is a sinusoid-like signal ...

5

This is one way to control the sound emission. Import a short .WAV file: sound = Import[ "ExampleData/rule30.wav" ] Now make sound only when your animation control reaches some value - k=0 or k=1 in this case: Animate[If[k == 0 || k == 1, EmitSound[sound]]; Plot[k*x^2, {x, -2, 2}, PlotRange -> {{-2, 2}, {-10, 10}}], {k, -2, 2, 0.1, AnimationRate ...

5

Here is a letter I got regarding this question from premier service technical support: Thank you for taking the time to send this in. Unfortunately, I do not believe this functionality currently exists in Mathematica and I have forwarded the suggestion that it be included in a future release of Mathematica to the developers in charge of this area. ...

5

Let's take an example of WAV sound data: data=Import[ "ExampleData/rule30.wav"] You can see sampling rate 44100 Hz and duration 1.8 s of your sample. This function extracts data for a specific time duration: TakeSound[d_, s_, e_] := {d[[1, 1, 1, Round[44100 s] ;; Round[44100 e]]]} And this app allows you to cut and play sub-samples of your data: ...

5

This answer addresses some of your question, which is actually fairly broad and I think touches as much on the underlying concepts as on how to use Mathematica to achieve the stated goal. This will answer: How to import a wav file as samples How to get the discrete Fourier transform normalized to give expected magnitudes How to get a range of frequencies ...

5

The answer was already given by Xerxes. It is a limitation of MIDI, which only supports 16 channels. That Mathematica really uses MIDI is described in the docs. For instance in the tutorial The Representation of Sound: At the lowest level, all sounds in Mathematica are represented as a sequence of amplitude samples, or as a sequence of MIDI events.

5

This should get you started: noise = RandomReal[1, {50000}]; snd1 = SampledSoundList[noise, 22050]; Sound[snd1] This plays about 2 seconds of noise when you press the button. You can add sounds before turning them into the SampledSoundList. So for instance: noise1 = RandomReal[1, {50000}]; noise2 = RandomReal[1, {50000}]; noise = noise1 + noise2; ...

4

The key to getting separate sounds to join smoothly is to make the waveform continuous. For example this sound contains an integer number of cycles, and we can emit a sequence of these with no audible gaps: testsound=Sound[SampledSoundFunction[Sin[0.4Pi #]&,1000,8000]]; Do[EmitSound[testsound],{5}] Contrast with this next one, where I have adjusted ...

Only top voted, non community-wiki answers of a minimum length are eligible