2 Answers
2

Try Export["~/Desktop/test.txt", Compress@sound] and in = Uncompress@Import["~/Desktop/test.txt"]. The way you did it, it gets imported as a string. There's other ways, but the one I present is what I always use to export/import arbitrary data structures: it's cross-platform and robust (as far as I can tell).

Now it will work - you need to read up on import/export of data on Documentation. This is fixes your specific code. But there are many ways to do this. For example to use "test.dat" format is better (no "Data" specification needed in Import). Or exporting sound itself (not the data) will work too - with the advantage that you can play it in other software:

The solution by .dat works fine here. But I encounterd the problem in a task, where not the sound itself has to be exported but only the data. And later on the data has to be imported back. Here is the example. First we got a wav-sound: tuba = ExampleData[{"Sound", "Tuba"}]; We extract the data: tubadat = ExampleData[{"Sound", "Tuba"}, "Data"]; Export["tubaDat.dat", tubadat]; in = Import[tubaDat.dat]; ListPlay[in] As you see, the replay of the imported file is distorted.
–
Hp Radojewski Schäfer VonDec 25 '12 at 15:18

Mathematica is a registered trademark of Wolfram Research, Inc. While the mark is used herein with the limited permission of Wolfram Research, Stack Exchange and this site disclaim all affiliation therewith.