Hot answers tagged

41

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


32

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


19

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


18

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]; interruptibleSpeak[...


18

One way to approach this is with "Dynamic Time Warping". First, preprocess your data to get the MFCC coefficients and extract the data from the time series: human = Audio["http://home.ustc.edu.cn/~xiaozh/SE/Audio/human.wav"]; hus = Audio["http://home.ustc.edu.cn/~xiaozh/SE/Audio/hus.wav"]; {humMFCC, husMFCC} = AudioLocalMeasurements[#, "MFCC"] & /@ {...


17

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


16

First, import the audio and extract usable data from it: audio = Sound[ SampledSoundList[ Flatten@ImageData@Import["https://i.stack.imgur.com/qHpp6.png"], 22050]] audioDuration = Duration[audio]; audioSampleRate = AudioSampleRate[audio]; data = AudioData[audio][[1]]; Second, use PeakDetect to see which points are peaks (= 1) and which points are ...


15

First let me observe that your coding style makes debugging difficult, I highly recommend breaking giant expressions into manageable pieces. Second, in the code below I have used a different definition for the segments. Your version: $y=(x-x_1)^{curvature}\frac{y_2-y_1}{x_2-x_1}+y_1$ does not give an amplitude of $y_2$ at $x=x_2$ if $curvature\neq1$. I ...


14

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.


14

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


14

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


14

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


14

What (I think) happens is that you use a constant rate of $8000\,\text{Hz}$ on a steady increasing frequency. This leads to interesting effects when the frequency of the function gets bigger than you rate-frequency. This fact can be explored by just using a $\sin$-Function and use a interval which is slightly larger than $\pi$ at example: Show[Plot[Sin[x], ...


13

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


13

Let's first try with a sound sample from MMA examples repository: s = Import["ExampleData/rule30.wav"] A FullForm of s reveals that this object has the structure Sound[SampledSoundList[{listOfSounds},samplesRate]]. From this it looks like to play the sound in reverse we just need to Reverse listOfSounds, which we can do for example like this: s /. ...


13

Import the subject audio: aud = Import["http://home.ustc.edu.cn/~xiaozh/SE/del_silences.wav"] Identify silences: silences = AudioIntervals[aud, #RMSAmplitude < 0.005 &]; Split the Audio object at the identified beginning and ends of the silence: splitAuds = AudioSplit[aud, Flatten[silences]]; Lengthen the silences (by replacing them with silence ...


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

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


12

One can also use Import[] to directly query the *.wav file's sample rate, like so: Import["ExampleData/rule30.wav", "SampleRate"] 44100


11

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


11

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.


11

The following resulted from a lot of spelunking and reading the code of Audio`Play. au = ExampleData[{"Audio", "Bird"}]; Audio`Internals`Execute[ Audio`Internals`GetAudioManager[ Audio`AudioInformation[au, "AudioID"]], "Play" ] Audio`Play does the same thing except it gets the "AudioID" in a different way which appears to fail. There are many other ...


11

An alternative to EvaluationCompletionAction would be to adjust $Post. Try Clear[f]; f[x___] := With[{}, Beep[]; x] $Post=f; Now Beep will also be evaluated once every evaluation. Use $Post=. to stop the beeping.


10

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


10

Here's how to "dial" the digits of $\pi$ on a touch tone phone (code adapted and modernized from an old Mathematica demo, but see this as well): touchToneList = Tuples[{{697, 770, 852, 941}, {1209, 1336, 1477}}]; playTouchTone[phonenumber : {__Integer}] := Play[Evaluate[Piecewise[ MapIndexed[{Total[Sin[2 π touchToneList[[#1]] t]], First[#...


10

You can also use Sound`AudioToSound[] to convert the Audio[] object to a Sound[] object that can then be passed to EmitSound[]: ExampleData[{"Audio", "Bird"}] // Sound`AudioToSound // EmitSound Of course, this is only recommended for modestly-sized Audio[] objects.


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

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


9

I let Mathematica parse the input into a speakable string, but then I send it to the operating system as if going through the command terminal. This allows me to set the voice flag for my installed voices. mySpeak[input_, voice_String:"Allison", options:OptionsPattern[Speak]]:= CompoundExpression[ Run["say -v " <> voice<>" " <> ...


9

solo = Import[ "ExampleData/rule30.wav" ] Cases[solo, (SampledSoundFunction | SampledSoundList)[__, r_] :> r, Infinity][[1]] 44100


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