New answers tagged

6

Duration = 9.95265 sec, frequency in Hz on x axis: music = Import["http://www.qlcoder.com/uploads/145425353234642.mp3", "mp3"]; amps = music[[1, 1, 1, All]]; namps = Length@amps; (* namps = 438912 corresponds to 9.95265 sec *) sr = 44100; (* your sampling rate in Hz *) inc = sr/namps; (* increment *) freq = Table[f, {f, 0, sr - inc, inc}] // N; y = ...


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


1

Play seems to have the property that it autoscales the volume to some constant level, regardless of the specified amplitude. The following code should play two tones, the first one loud and the second one quiet: louddot := Play[Sin[2000 t], {t, 0, 1}, SampleRate -> 22050]; quietdot := Play[0.01 Sin[2000 t], {t, 0, 1}, SampleRate -> 22050]; ...


0

I will give the morse code - generating part of this question another go: First let's query Wolfram Alpha for some morse code: query[letter_]:= WolframAlpha["morse code " <> letter, "PodPlaintext"][[2]] and create an Association for easy lookup charToMorse = query ~AssociationMap~ CharacterRange["A","Z"] The following function translates a given ...


3

I don't exactly know why your version doesn't work, but who wants to use loops anyway? Here's a Table version that works: tones = Table[With[{j = j}, Play[Sin[2*Pi*t*500/Exp[-0.1*j/20]], {t, 0, 1}]], {j, 0, 40}] For some reason, putting the With in there makes it work, whereas without the With, it doesn't. This also makes your code work: tones = {}; ...



Top 50 recent answers are included