First time here? Check out the FAQ!
x

Export a sample to a text file

0 votes
57 views
Hi SSC,

I've been doing some work with 4096 sample length files and I'd like to export or ideally batch convert samples to text files so I can create charts to use as icons for the samples. I know you can import a text file into the sample editor; I'm sure it would be possible to go the other way but I have no idea where to start.

Can you or anyone else advise?

Thanks,
Sean
asked May 3 in Using Kyma by sean-flannery (Adept) (1,330 points)

1 Answer

0 votes

Hi Sean,

Sorry it's not a Kyma solution, but if you know how to use Python, you will also need to install numpy and librosa.
In the mean time, it would be more convenient if your sample files are mono.  Multichannel sound files are stored differently based on the type of files (wav, aiff, etc..). 

Here is the code you can use:


import numpy, librosa
x, sr = librosa.load('soundfile.wav')
numpy.savetxt("soundfile.csv", x, delimiter=",")

answered May 4 by allen-wu (Practitioner) (340 points)
Thanks Alan,
While researching this question I found a freeware app called Audacity can save audio as csv. Tip for anyone anyone going down this path - choose linear measurement scale on the sample data export dialog. Charts of dB values dont look like what you'd expect ;)
Thanks for letting me know.   I was trying in Audacity first but didn't find the function.
...