Magellan Linux

Contents of /trunk/audiofile/patches/audiofile-0.2.6-sfconvert-eradicator-2.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 407 - (show annotations) (download)
Tue Nov 13 15:36:43 2007 UTC (16 years, 6 months ago) by niro
File size: 4501 byte(s)
-added versionized patch

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