Prev: How to Determine Highest Precision Available on a PC ??
Next: gcc4.4: f951: warning: command line option "-MM" is valid for C/C++/Java/ObjC/ObjC++ but not for Fortran
From: Gary L. Scott on 10 Aug 2010 20:25 On 8/9/2010 11:50 AM, Mohammed Anwer wrote: > This may already have been answer many times on this forum. Can anyone > point me to an example program that reads/writes an audio .wav file? > > Thanks in advance. Was for a specialized purpose, but here is an example of reading a wave file expected to be produced by a specific application. http://www.fortranlib.com/waveread.f90
From: Gary L. Scott on 10 Aug 2010 20:27 On 8/10/2010 7:25 PM, Gary L. Scott wrote: > On 8/9/2010 11:50 AM, Mohammed Anwer wrote: >> This may already have been answer many times on this forum. Can anyone >> point me to an example program that reads/writes an audio .wav file? >> >> Thanks in advance. > > Was for a specialized purpose, but here is an example of reading a wave > file expected to be produced by a specific application. > > http://www.fortranlib.com/waveread.f90 Oh, you can ignore the byteswap section, I had to reformat it for a big endian machine.
From: Gary L. Scott on 10 Aug 2010 21:49 On 8/10/2010 7:27 PM, Gary L. Scott wrote: > On 8/10/2010 7:25 PM, Gary L. Scott wrote: >> On 8/9/2010 11:50 AM, Mohammed Anwer wrote: >>> This may already have been answer many times on this forum. Can anyone >>> point me to an example program that reads/writes an audio .wav file? >>> >>> Thanks in advance. >> >> Was for a specialized purpose, but here is an example of reading a wave >> file expected to be produced by a specific application. >> >> http://www.fortranlib.com/waveread.f90 > > Oh, you can ignore the byteswap section, I had to reformat it for a big > endian machine. P.P.S the reason dynamic allocation isn't used is because there is a maximum design limit to the output file for this particular application. No need to process a wave file if it can't be represented in the output. This was written in the early 90's, i see a few things i'd do differently, but it should be fairly easy to follow.
From: JKB on 11 Aug 2010 08:05 Le Tue, 10 Aug 2010 23:54:20 +0200, Tonton Th <tth(a)la.bas.invalid> écrivait : > On 08/09/2010 06:50 PM, Mohammed Anwer wrote: >> This may already have been answer many times on this forum. Can anyone >> point me to an example program that reads/writes an audio .wav file? >> >> Thanks in advance. > > I've doing that in the past for g77 and libsndfile. > http://tontonth.free.fr/libsound77.html Je l'savais ! > I'm currently thinking about a version for gfortran. Don't fall in dark side ;-) JKB -- Le cerveau, c'est un véritable scandale écologique. Il représente 2% de notre masse corporelle, mais disperse à lui seul 25% de l'énergie que nous consommons tous les jours. => http://grincheux.de-charybde-en-scylla.fr
From: tholen on 11 Aug 2010 17:41
glen herrmannsfeldt <gah(a)ugcs.caltech.edu> writes: > Mohammed Anwer <manwer(a)gmail.com> wrote: >> This may already have been answer many times on this forum. Can anyone >> point me to an example program that reads/writes an audio .wav file? > I have some C programs that can read/write them. There is some > information in the header, otherwise some just remove the appropriate > number of bytes and expect pairs of 16 bit words. As I understand it, the various chunks can appear in any order and still be standard-conforming. However, I have never encountered a WAV file that didn't have all the format information at the head of a file, with the data chunk coming last, so that streaming could be supported. If the format information came after the data, one would be forced to download all the data before knowing how to play it properly. There are a lot of digital audio recorders out there now that support 24-bit samples, so I wouldn't be quite so certain about expecting pairs of 16-bit words. I recently tested Linux's support for these deeper bit depths by plugging in a digital audio recorder to a computer via its USB port and then using the file browser to look at the contents of the recorder's memory. Hovering the mouse over a WAV icon causes Linux to play the file, and it had no trouble playing a 24-bit 96 kHz recording. Too bad there is no native 24-bit integer type in Fortran. You need to read such a file either as 3-byte character strings or as a set of three 1-byte integers. For stereo, the samples are interleaved. The WAV format allows for more than two channels, though I have yet to encounter a WAV file that uses the capability. In fact, I have a digital audio recorder that can record four channels simultaneously, and rather than using a single WAV file with the number of channels set to four, it instead writes two stereo WAV files. Go figure. |