Hot answers tagged

32

This is not the full answer but I've solved most of the problems. The hardest one, with sound, remains. Embedded version without music bobthechemist's points Quality is not a problem anymore since here nothing is rasterized. White edges are due to "features" with Texture, I've fixed that using strange VertexTextureCoordinates. I can't handle this ...


29

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 = ...


20

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 ...


18

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[#]]) ...


18

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 ...


17

Running Trace[Speak["Hello"]] and Names["*Speak*"] revealed the following possibility: MathLink`CallFrontEnd[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]; ...


15

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]], ...


15

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"];


14

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 = ...


13

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, ...


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 ...


12

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.


12

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 ...


12

Here is an explicit way to calculate the frequency corresponding to each element of the output of the Fourier command. The frequencies will depend on two values: the sampling interval and the number of points in the data analysis. ssf = RotateRight[Range[-n/2, n/2 - 1]/(n sampInt), n/2]; where n is the number of points analyzed and sampInt is the time ...


12

You can see the spectrum of the first note played, (first 40000 points) ListLogLogPlot[ {#, # PeakDetect[#, 5, 10^-2]} &@ Abs@Fourier@music[[1, 1, 1, 1 ;; 40000]] , Joined -> {True, False} , PlotStyle -> {Gray, Red} , Filling -> Axis , PlotRange -> {{100, 1000}, All} , PlotTheme -> "Scientific"] But beware that the scaling is ...


11

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 ...


10

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

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}, ...


9

I'd do something like this. Pause[5]; Speak["Done Pausing for 5 Seconds"]


9

SystemDialogInput["RecordSound"] will bring up a dialog that let's you record sound. It works both on Windows and Mac in v9, but only on Windows in earlier versions. It doesn't work on Linux. But what if you need to record sound without user interaction, and you want to avoid a modal dialog? The right way is to use some external and documented tool (e.g. ...


9

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]] ...


9

There was a symbol called StartupSound. You could switch it on via the command: SetOptions[$FrontEnd, StartupSound -> True] But according to Wolfram Reference it is no longer available.


8

How about solving the harmonic oscillator equation with a time-varying frequency? w[t_] := 2 Pi (440 + 5 Sin[10 * 2 Pi t]) func = NDSolveValue[{y''[t] + w[t]^2 y[t] == 0, y[0] == 1, y'[0] == 0}, y, {t, 0, 4}]; Play[func[t], {t, 0, 4}]


8

As an alternative, let's let the derivative of the phase vary with time. A fixed tone will have $d \phi / d t = 2 \pi \cdot 440$. A vibrato that you want should have $d \phi / d t = 2 \pi (440 + \sin (2\pi\cdot5\cdot t))$. Integrating: Integrate[440*2 π + 2 π Sin[5*2 π x], {x, 0, t}] (* 880 π t + 2/5 Sin[5 π t]^2 *) Playing: Play[Sin[880 π t + 2/5 Sin[5 ...


8

About a year ago,I saw a demo in Labview that can detect the voice of killer whale in a setting of the sound of seawater. I want to try the similar thing in Mathematica. Based upon Vitaliy Kaurov's approach: voice = ExampleData[{"Sound", "Apollo11ReturnSafely"}]; data = voice[[1, 1, 1]]; r = voice[[1, 2]]; cwt = ContinuousWaveletTransform[data, ...


7

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]], ...


7

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.


7

The $k^\text{th}$ element of the result will be the coefficient of the wave that has $k-1$ full periods in the complete sample. Thus if the length of your sample is $t$ time units, the $k^\text{th}$ element of the result will correspond to frequency $\frac{k-1}{t}$, regardless of the sample rate. It should be noted that due to aliasing, element $k$ of a ...


7

The first step is to convert the sounds to one of the supported formats. I recommend WAV or FLAC. Then you can Import it. You'll get an expression of the form Sound[SampledSoundList[{leftChannel, rightChannel}, sampleRate]] where rightChannel and leftChannel are numerical lists of amplitudes. Generally, if you want to hear the sound from just the left ...


7

In general, when you want to share a notebook and a data file, it is easier if you use reference the file from a well defined location that is either: An absolute path that depends on the OS/user such as $HomeDirectory or $TemporaryDirectory. A directory relative to the directory that the notebook is in (you can move up/down the tree starting from ...



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