brauche Hilfe, Audiodatei in ASCII,csv konvertieren

Gast #2055634
Lesenswert?

Hallo,

wie kann ich eine Audio Datei, aufgenommen mit z.B. Audacity, in in 
Ascii Werte umwandeln.
Hintergrund, ich habe eine Controllerprogramm und möchte den Audiocode 
dort "durchjagen", sprich eine Simulation fahren.
Also gibt es ein Tool um Mono Audiodaten in eine csv datei zu wandeln ?

schon mal vielen Dank für eure Hilfe
Robert
Gast #2055975
Lesenswert?

sox, der Chuck Norris unter den Audioconvertern, kennt ein .dat-Format:

"Text Data files. These files contain a textual representation of the 
sample data. There is one line at the beginning that contains the sample 
rate. Subsequent lines contain two numeric data items: the time since 
the beginning of the first sample and the sample value. Values are 
normalized so that the maximum and minimum are 1 and -1. This file 
format can be used to create data files for external programs such as 
FFT analysers or graph routines. SoX can also convert a file in this 
format back into one of the other file formats."

Wenn das nicht so aussieht, wie Du das brauchst, dann würde ich an 
Deiner Stelle vermutlich selber was programmieren, z.B. mit libsndfile ( 
http://www.mega-nerd.com/libsndfile/ ) für den Import.

Mirko
Gast #2056044
Lesenswert?

1
#!/usr/bin/python
2

3
#benutzen mit 
4
#       python diesedatei.py in.wav out.csv
5

6
import wave
7
import sys
8
import struct
9

10
infile = wave.open(sys.argv[1], 'r')
11
outfile = open(sys.argv[2], 'w')
12
num_samples = infile.getnframes()
13
for i in range(0, num_samples):
14
    frame = infile.readframes(1)
15
    number = struct.unpack('h', frame)[0]
16
    line = str(i) + ';' + str(number) + '\n'
17
    outfile.write(line)
18
infile.close()
19
outfile.close()

Scheint zu funktionieren und ist leicht anzupassen.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren