Converting AIFF to text

Discussion forum for Amadeus users

Moderator: Martin Hairer

Post Reply
lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Converting AIFF to text

Post by lemallard »

I am looking to do time-based analysis of the AIFF files that I am creating. (In contrast to frequency-based.) This requires that I convert the AIFF file into something that I can analyze directly, such as a txt file.

I can read the AIFF file in a text editor, but I need to convert the data.

Does anyone have any suggestions on how I can accomplish this, and where I can get a symbol list to perform the conversion myself?

CDJonah_alt
Posts: 379
Joined: Thu Mar 15, 2007 3:57 pm

Converting AIFF to text

Post by CDJonah_alt »

Years ago in a country far away, I used Amadeus (some earlier version)
to write a raw data file out. I then analyzed the data using a simple C
program that I wrote (my first and last C program). I then wrote the
output out and then had Amadeus read it and turn it back into an Aiff
flle. This was for a power pc so of course the bytes were swapped from
the intel.

Probably as easy a route as any is to dump a raw file, read the data
in, byte/word by byte/wordand then print out the values in text to the
screen and pipe the screen to a file.

Chuck
On 9/19/12 10:38 AM, lemallard wrote:
I am looking to do time-based analysis of the AIFF files that I am creating. (In contrast to frequency-based.) This requires that I convert the AIFF file into something that I can analyze directly, such as a txt file.

I can read the AIFF file in a text editor, but I need to convert the data.

Does anyone have any suggestions on how I can accomplish this, and where I can get a symbol list to perform the conversion myself?




_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list
--
Charles D Jonah
Building 200
Chemical Sciences and Engineering Division
9700 S. Cass Avenue
Argonne, IL 60439
630-252-3471 CDJonah@anl.gov

_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

That is exactly what I am looking to do. However, as I read the file in its native format, the symbols are ineligible. So, I will also need to know what the symbol list is--unless what I am reading is native to Amadeus.

CDJonah
Posts: 119
Joined: Sat Nov 11, 2006 12:10 am

Converting AIFF to text

Post by CDJonah »

Did you read it as a raw file?

I don't think it is practicable to read it into a text editor -- most of
the values are not normal text values -- some will be control
characters, etc.

I can probably find my old C program and rearrange it to generate bytes
to text and then you can read the data in and re-interpret it (have to
put bytes back into 16-bit words, worry about sign, etc.)

Chuck

On 9/19/12 12:34 PM, lemallard wrote:
That is exactly what I am looking to do. However, as I read the file in its native format, the symbols are ineligible. So, I will also need to know what symbol list is--unless what I am reading is native to Amadeus.




_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

Yes, I read it as a raw file. Looking at your C-code would be a good start. :)

CDJonah
Posts: 119
Joined: Sat Nov 11, 2006 12:10 am

Converting AIFF to text

Post by CDJonah »

Okay, I will need to find it -- maybe tonight

chuck

On 9/19/12 11:07 PM, lemallard wrote:
Yes, I read it as a raw file. Looking at your C-code would be a good start. :)




_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

Thanks. I know that this is obscure, but it is necessary. :)

CDJonah
Posts: 119
Joined: Sat Nov 11, 2006 12:10 am

Converting AIFF to text

Post by CDJonah »

It would be except I must have deleted that folder. I have traces of
the program but nothing useful any more. I went back a couple of backups
and still couldn't find it. It may well have been 5 or more years ago.

As I recall, I read the file in byte by byte, put the two bytes together
to make the word and went from there. But I wouldn't want to count on my
memory as I seemed to have deleted everything and I don't remember that.
It was an old laptop with a limited disk drive..

Chuck

On 9/19/12 11:07 PM, lemallard wrote:
Yes, I read it as a raw file. Looking at your C-code would be a good start. :)




_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

_______________________________________________
Amadeus forum mailing list
Unsubscribe / change settings at http://two.pairlist.net/mailman/listinfo/forum_list

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

Thanks for the effort, Chuck. I am assuming that I will be able to read this directly, even though it is not a text file. The question now is the format of the file.

rockbottom
Posts: 12
Joined: Tue Jun 28, 2011 11:13 am

Post by rockbottom »

if you are a programmer the simplest solution would be to use the python language with one of the aif, wav, or audio op modules available from the python standard library:

http://docs.python.org/modindex.html

I tried that approach some time ago, using the aifc module, and I didn't have to worry about what you call the format of the file: it will only take you one line of code to open an aiff file, and another one to read its audio frames; plus any manipulations you'd want to perform on that data, of course;

from my experience, developing such a program is certainly faster than when using the C language... the drawback is that the performance is way slower but for a one-shot program, it's alright!

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

Thank you, rockbottom! That does sound much, much simpler. I do not use Python, but I am more than happy to learn to do so, if it simplifies this problem for me!

rockbottom
Posts: 12
Joined: Tue Jun 28, 2011 11:13 am

Post by rockbottom »

ah, not only does it sound simple but since python code looks much like english, it is actually very simple; all you'll have to learn is how to open a terminal window and type a command...

for instance, if the python program is:

Code: Select all

import aifc, sys
if len(sys.argv) is not 2: exit('file name expected')
stream = aifc.open(sys.argv[1], 'r')
print 'mono' if stream.getnchannels() is 1 else 'stereo',
print stream.getsampwidth() * 8, 'bits,',
print stream.getframerate(), 'Hz sampling rate'
data = stream.readframes(stream.getnframes())
print len(data), 'bytes read'
and this script is saved in a file called read-a.py in your home directory, here is the command to execute the script and read the file named sample.aif, also in your home directory:

Code: Select all

python read-a.py sample.aif
and then the program would display something like:

Code: Select all

stereo 16 bits, 44100 Hz sampling rate
9663652 bytes read

lemallard
Posts: 7
Joined: Wed Sep 19, 2012 3:30 pm

Post by lemallard »

Thank you again! When I work on this, I will get back to you about how I did it. This is clearly a good route to take.

Post Reply