Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Exporting Sound

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83845] RE: [mg83821] Exporting Sound
  • From: "Ingolf Dahl" <ingolf.dahl at telia.com>
  • Date: Sun, 2 Dec 2007 04:10:14 -0500 (EST)
  • References: <200712011048.FAA28346@smc.vnet.net>

Helen,
The Mathematica Help is not very pedagogic in this issue, but there are two
types of sounds, represented by Mathematica, and they cannot mix. The
difference is analogous to the difference between raster graphics and
vectors graphics:

1. Waveform sound, type recorded sound or sound generated by 
 Play[(2 + Cos[20 t]) * Sin[3000 t + 2 Sin[50 t] ], {t, 0, 2}]
correspond to raster graphics.
Such sounds can be exported to WAV files without problems. They are sent to
the sound card as a stream of sampled voltage levels, and directly fed to a
DA converter. Reading was a problem with early versions of Mathematica,
since the reading was stopped as soon as a end-of-file sign was found, and
it is a plenty of such signs in these files.

2. Note-based sound of type
 SoundNote["F", 1, "Tinklebell"]
is similar to vector graphics.
Here the sound is sent to the sound card as MIDI commands, which is just a
simple conversion of the Mathematica commands. The sound card uses the
built-in synth to produce the sound. If such sounds are to be exported from
Mathematica, .MID is the relevant file format.

For note-based sound Mathematica does not "know" what the waveform is, and
thus cannot translate the second type to the first. I guess that this
ability already is placed on the to-do list at Wolfram, but with low
priority. The simplest way to achieve the transformation is to hook-up two
computers, one playing the sound and the other recording. If you are more
clever, you might do the same trick with one computer. You could also find
(free or shareware) software on the net, doing the conversion inside the
computer. Maybe someone has written a Mathematica package? Search for
"software synth" or "mid2wav" to get started, and check also what Winamp can
do. To go in the other direction is trickier, but not completely impossible
(requires commercial software).

Best regards

Ingolf Dahl




> -----Original Message-----
> From: Helen Read [mailto:hpr at together.net] 
> Sent: den 1 december 2007 11:48
> To: mathgroup at smc.vnet.net
> Subject: [mg83821] Exporting Sound
> 
> Has anyone succeeded in exporting sounds (as .wav) from v.6? 
> The documentation indicates that this is possible, but I 
> could not find a single example of how to actually do it.
> 
> As a simple example (I'm actually working with far more 
> complicated sounds), try this.
> 
> ding = SoundNote["F", 1, "Tinklebell"];
> 
> Sound[ding] brings up a GUI for playing the ding sound.
> 
> EmitSound[Sound[ding]] can be used to play the sound programatically.
> 
> But what is it that I'm supposed to export?
> 
> Export["ding.wav",ding] does not work,
> 
> nor does Export["ding.wav",Sound[ding]]
> 
> nor does Export["ding.wav",EmitSound[Sound[ding]]]
> (I admit this last was a longshot, but I tried everything I 
> could think of.)
> 
> Depending on whether I try to export the SoundNote itself, or 
> the Sound, or the EmitSound, I get error messages like:
> 
> First::normal: Nonatomic expression expected at position 1 in 
> First[None].
> 
> Or:
> 
> Export::nodta: "Null contains no data that can be exported to 
> the WAV format."
> 
> Or:
> 
> Export::nodta: <<1>> contains no data that can be exported to 
> the WAV format."
> 
> So again, what is that I'm supposed to export?
> 
> --
> Helen Read
> University of Vermont
> 
> 




  • Prev by Date: Re: Interpolation in 2 D, bug?
  • Next by Date: Re: Vieta infinite product formula
  • Previous by thread: Exporting Sound
  • Next by thread: Re: Exporting Sound