I was exporting a 60 second audio clip last night, and after waiting half an hour I went to bed. (The export had completed by the time I woke up this morning.)
Why does Mathematica require over 30 minutes for a job like this when any half decent free audio app can do it in seconds?
Before I do that, do you really think the complexity of the sound could slow down the mpg3 encoding algorithm? I don’t know much about it. Would that apply to a wav export also?
The first note in the Details and Options section of [Sound documentation] (Sound—Wolfram Documentation) lists which primitives can be used in the Sound object. One of these primitives, SampledSoundList, stores sampled audio data and can be exported directly to any audio file format. This means the following will be fast:
If a Sound object contains any other primitives (SampledSoundFunction or SoundNote), then it has to be “rasterized” to contain only SampledSoundList primitives. This process may take a long time if SampledSoundFunction is complicated.
Wait, I’m uncertain how to handle this. Once I’ve generated the Sound object I can play it immediately and repeatedly with no delay. But if I save it to a variable, I get the same problem:
The Audio constructor is called by Export if the expression you are trying to export is not already an Audio object. You can use AudioQ to test if your expression is an Audio object.
So maybe the solution is to avoid Play and use SampledSoundList directly?
It seems strange that Mathematica generates the audio for playback but must regenerate it for export - presumably that’s because settings are redone for the mp3 format?
Btw, another serious problem I’m having is that every time I try to play an Audio object the kernel crashes. I assume this is because of incompatibilities with the linux sound system.
Does that mean on linux there is no way to avoid generating the audio twice - once for playing, once for saving?
OK, now I’m running into a problem with SampledSoundList. Are there strict requirements on soundlists that can be exported to various formats?
In[112]:= AbsoluteTiming@Export["test.mp3", sound]
During evaluation of In[112]:= Export::nodta: Sound[SampledSoundList[{0.00914949,0.0645038,0.10364,0.119694,0.118204,0.11123,0.108125,<<37>>,-0.0343303,-0.0115127,0.0102955,0.0199559,0.0169125,0.00949124,<<176351>>},<<1>>]] contains no data that can be exported to the MP3 format.
Out[112]= {0.413006, $Failed}
You cannot export to mp3 sounds that are shorter than 0.1 seconds. Other file formats don’t have such restriction. Please attach a file with the InputForm of your Sound object.
I had set the sample depth to 16, isn’t that the standard for mp3? If I leave the sample depth unset, ListPlay defaults it to 8. Does that mean the mp3 file written by Mathematica will have sample depth 8?