Annotation of /trunk/audiofile/patches/sfconvert-eradicator.patch
Parent Directory | Revision Log
Revision 144 -
(hide annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 4345 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 4345 byte(s)
-import
1 | niro | 144 | --- sfconvert.c.orig 2004-04-04 23:39:56.000000000 -0700 |
2 | +++ sfconvert.c 2004-04-05 00:00:25.000000000 -0700 | ||
3 | @@ -66,12 +66,14 @@ | ||
4 | |||
5 | AFfilehandle infile, outfile; | ||
6 | AFfilesetup outfilesetup; | ||
7 | - int sampleFormat, sampleWidth, channelCount; | ||
8 | - double sampleRate; | ||
9 | + int sampleFormat, sampleWidth, channelCount, byteOrder; | ||
10 | + double sampleRate, outSampleRate; | ||
11 | + int outSampleRateInt = -1; | ||
12 | int outSampleFormat = -1, outSampleWidth = -1, | ||
13 | - outChannelCount = -1; | ||
14 | + outChannelCount = -1, outByteOrder = -1; | ||
15 | double outMaxAmp = 1.0; | ||
16 | |||
17 | + | ||
18 | AFframecount totalFrames; | ||
19 | |||
20 | if (argc < 3) | ||
21 | @@ -88,7 +90,10 @@ | ||
22 | { | ||
23 | if (i + 1 >= argc) | ||
24 | usageerror(); | ||
25 | - if (!strcmp(argv[i+1], "aiff")) | ||
26 | + | ||
27 | + if (!strcmp(argv[i+1], "raw")) | ||
28 | + outFileFormat = AF_FILE_RAWDATA; | ||
29 | + else if (!strcmp(argv[i+1], "aiff")) | ||
30 | outFileFormat = AF_FILE_AIFF; | ||
31 | else if (!strcmp(argv[i+1], "aifc")) | ||
32 | outFileFormat = AF_FILE_AIFFC; | ||
33 | @@ -98,6 +103,12 @@ | ||
34 | outFileFormat = AF_FILE_NEXTSND; | ||
35 | else if (!strcmp(argv[i+1], "bics")) | ||
36 | outFileFormat = AF_FILE_BICSF; | ||
37 | + else if (!strcmp(argv[i+1], "avr")) | ||
38 | + outFileFormat = AF_FILE_AVR; | ||
39 | + else if (!strcmp(argv[i+1], "iff")) | ||
40 | + outFileFormat = AF_FILE_IFF_8SVX; | ||
41 | + else if (!strcmp(argv[i+1], "nist")) | ||
42 | + outFileFormat = AF_FILE_NIST_SPHERE; | ||
43 | else | ||
44 | { | ||
45 | fprintf(stderr, "sfconvert: Unknown format %s.\n", argv[i+1]); | ||
46 | @@ -107,6 +118,22 @@ | ||
47 | /* Increment for argument. */ | ||
48 | i++; | ||
49 | } | ||
50 | + else if (!strcmp(argv[i], "byteorder")) | ||
51 | + { | ||
52 | + if (i + 1 >= argc) | ||
53 | + usageerror(); | ||
54 | + | ||
55 | + if(!strcmp("big", argv[i+1])) { | ||
56 | + outByteOrder = AF_BYTEORDER_BIGENDIAN; | ||
57 | + } else if(!strcmp("little", argv[i+1])) { | ||
58 | + outByteOrder = AF_BYTEORDER_LITTLEENDIAN; | ||
59 | + } else { | ||
60 | + usageerror(); | ||
61 | + } | ||
62 | + | ||
63 | + /* Increment for argument. */ | ||
64 | + i++; | ||
65 | + } | ||
66 | else if (!strcmp(argv[i], "channels")) | ||
67 | { | ||
68 | if (i + 1 >= argc) | ||
69 | @@ -119,6 +146,20 @@ | ||
70 | /* Increment for argument. */ | ||
71 | i++; | ||
72 | } | ||
73 | + else if (!strcmp(argv[i], "rate")) | ||
74 | + { | ||
75 | + if (i + 1 >= argc) | ||
76 | + usageerror(); | ||
77 | + | ||
78 | + outSampleRateInt = atoi(argv[i+1]); | ||
79 | + if (outSampleRateInt <= 0) | ||
80 | + usageerror(); | ||
81 | + | ||
82 | + outSampleRate = (double)outSampleRateInt; | ||
83 | + | ||
84 | + /* Increment for argument. */ | ||
85 | + i++; | ||
86 | + } | ||
87 | else if (!strcmp(argv[i], "float")) | ||
88 | { | ||
89 | if (i + 1 >= argc) | ||
90 | @@ -170,6 +211,7 @@ | ||
91 | totalFrames = afGetFrameCount(infile, AF_DEFAULT_TRACK); | ||
92 | channelCount = afGetChannels(infile, AF_DEFAULT_TRACK); | ||
93 | sampleRate = afGetRate(infile, AF_DEFAULT_TRACK); | ||
94 | + byteOrder = afGetByteOrder(infile, AF_DEFAULT_TRACK); | ||
95 | afGetSampleFormat(infile, AF_DEFAULT_TRACK, &sampleFormat, &sampleWidth); | ||
96 | |||
97 | /* Initialize output audio format parameters. */ | ||
98 | @@ -184,14 +226,21 @@ | ||
99 | outSampleWidth = sampleWidth; | ||
100 | } | ||
101 | |||
102 | + if (outByteOrder == -1) | ||
103 | + outByteOrder = byteOrder; | ||
104 | + | ||
105 | if (outChannelCount == -1) | ||
106 | outChannelCount = channelCount; | ||
107 | |||
108 | + if (outSampleRateInt == -1) | ||
109 | + outSampleRate = sampleRate; | ||
110 | + | ||
111 | afInitFileFormat(outfilesetup, outFileFormat); | ||
112 | afInitSampleFormat(outfilesetup, AF_DEFAULT_TRACK, outSampleFormat, | ||
113 | outSampleWidth); | ||
114 | afInitChannels(outfilesetup, AF_DEFAULT_TRACK, outChannelCount); | ||
115 | - afInitRate(outfilesetup, AF_DEFAULT_TRACK, sampleRate); | ||
116 | + afInitRate(outfilesetup, AF_DEFAULT_TRACK, outSampleRate); | ||
117 | + afInitByteOrder(outfilesetup, AF_DEFAULT_TRACK, outByteOrder); | ||
118 | |||
119 | outfile = afOpenFile(outfilename, "w", outfilesetup); | ||
120 | if (outfile == AF_NULL_FILEHANDLE) | ||
121 | @@ -228,6 +277,7 @@ | ||
122 | printf("\n"); | ||
123 | |||
124 | printf("Where keywords specify format of input or output soundfile:\n"); | ||
125 | + printf(" rate n sample rate (22050, 44100, 48000, etc.)\n"); | ||
126 | printf(" byteorder e endian (e is big or little)\n"); | ||
127 | printf(" channels n n-channel file (1 or 2)\n"); | ||
128 | printf(" format f file format f (see below)\n"); | ||
129 | @@ -239,11 +289,15 @@ | ||
130 | |||
131 | printf("Currently supported formats are:\n"); | ||
132 | printf("\n"); | ||
133 | + printf(" raw \n"); | ||
134 | printf(" aiff Audio Interchange File Format\n"); | ||
135 | printf(" aifc AIFF-C File Format\n"); | ||
136 | printf(" next NeXT/Sun Format\n"); | ||
137 | printf(" wave MS RIFF WAVE Format\n"); | ||
138 | printf(" bics Berkeley/IRCAM/CARL Sound File Format\n"); | ||
139 | + printf(" avr Audio Visual Research File Format\n"); | ||
140 | + printf(" iff Amiga IFF/8SVX Sound File Format\n"); | ||
141 | + printf(" nist NIST SPHERE File Format\n"); | ||
142 | printf("\n"); | ||
143 | |||
144 | exit(EXIT_FAILURE); |