@@ -15,6 +15,7 @@ public class PCMFileInfo
1515 public byte [ ] raw { get ; private set ; } = null ;
1616 public byte [ ] encData { get ; private set ; } = null ;
1717 private bool is16bit ;
18+ public bool rev { get ; set ; } = false ;
1819
1920 public PCMFileInfo ( List < string > itemList , Func < string , Stream > appendFileReaderCallback = null )
2021 {
@@ -48,6 +49,7 @@ public PCMFileInfo(List<string> itemList, Func<string, Stream> appendFileReaderC
4849 if ( itemList . Count > 1 ) name = itemList [ 1 ] ;
4950 if ( itemList . Count > 2 ) fileName = itemList [ 2 ] ;
5051 if ( itemList . Count > 3 && int . TryParse ( itemList [ 3 ] , out n ) ) volume = n ;
52+ if ( itemList . Count > 4 ) rev = ( itemList [ 4 ] . ToUpper ( ) == "R" ) ;
5153
5254 byte [ ] buf ;
5355 using ( Stream pd = appendFileReaderCallback ? . Invoke ( fileName ) )
@@ -61,7 +63,7 @@ public PCMFileInfo(List<string> itemList, Func<string, Stream> appendFileReaderC
6163 {
6264 bool isRaw ;
6365 int samplerate ;
64- raw = GetPCMDataFromFile ( "" , fileName , volume , out isRaw , out is16bit , out samplerate ) ;
66+ raw = GetPCMDataFromFile ( "" , fileName , volume , rev , out isRaw , out is16bit , out samplerate ) ;
6567 if ( raw != null ) length = ( ushort ) raw . Length ;
6668 else
6769 throw new mucomDotNET . Common . MucException ( string . Format ( "Fail get pcm data from file[{0}]." , fileName ) ) ;
@@ -75,7 +77,7 @@ public PCMFileInfo(List<string> itemList, Func<string, Stream> appendFileReaderC
7577 {
7678 bool isRaw ;
7779 int samplerate ;
78- raw = GetPCMDataFromFile ( buf , volume , out isRaw , out is16bit , out samplerate ) ;
80+ raw = GetPCMDataFromFile ( buf , volume , rev , out isRaw , out is16bit , out samplerate ) ;
7981 if ( raw != null ) length = ( ushort ) raw . Length ;
8082 else
8183 throw new mucomDotNET . Common . MucException ( string . Format ( "Fail get pcm data from file[{0}]." , fileName ) ) ;
@@ -126,7 +128,7 @@ public void Encode(enmFormatType formatType)
126128 length = encData . Length ;
127129 }
128130
129- public static byte [ ] GetPCMDataFromFile ( string path , string fileName , int vol , out bool isRaw , out bool is16bit , out int samplerate )
131+ public static byte [ ] GetPCMDataFromFile ( string path , string fileName , int vol , bool rev , out bool isRaw , out bool is16bit , out int samplerate )
130132 {
131133 string fnPcm = Path . Combine ( path , fileName ) . Replace ( '\\ ' , Path . DirectorySeparatorChar ) . Replace ( '/' , Path . DirectorySeparatorChar ) ;
132134
@@ -149,10 +151,10 @@ public static byte[] GetPCMDataFromFile(string path, string fileName, int vol, o
149151 return buf ;
150152 }
151153
152- return GetPCMDataFromFile ( buf , vol , out isRaw , out is16bit , out samplerate ) ;
154+ return GetPCMDataFromFile ( buf , vol , rev , out isRaw , out is16bit , out samplerate ) ;
153155 }
154156
155- public static byte [ ] GetPCMDataFromFile ( byte [ ] buf , int vol , out bool isRaw , out bool is16bit , out int samplerate )
157+ public static byte [ ] GetPCMDataFromFile ( byte [ ] buf , int vol , bool rev , out bool isRaw , out bool is16bit , out int samplerate )
156158 {
157159 isRaw = false ;
158160 is16bit = false ;
@@ -276,6 +278,18 @@ public static byte[] GetPCMDataFromFile(byte[] buf, int vol, out bool isRaw, out
276278 des [ i ] = ( byte ) ( b & 0xff ) ;
277279 des [ i + 1 ] = ( byte ) ( ( b & 0xff00 ) >> 8 ) ;
278280 }
281+ if ( rev )
282+ {
283+ for ( int i = 0 ; i < des . Length / 2 ; i += 2 )
284+ {
285+ byte l = des [ i ] ;
286+ byte m = des [ i + 1 ] ;
287+ des [ i ] = des [ des . Length - 1 - i - 1 ] ;
288+ des [ i + 1 ] = des [ des . Length - 1 - i - 0 ] ;
289+ des [ des . Length - 1 - i - 1 ] = l ;
290+ des [ des . Length - 1 - i - 0 ] = m ;
291+ }
292+ }
279293 }
280294 else
281295 {
@@ -294,6 +308,15 @@ public static byte[] GetPCMDataFromFile(byte[] buf, int vol, out bool isRaw, out
294308
295309 des [ i ] = ( byte ) d ;
296310 }
311+ if ( rev )
312+ {
313+ for ( int i = 0 ; i < des . Length / 2 ; i ++ )
314+ {
315+ byte l = des [ i ] ;
316+ des [ i ] = des [ des . Length - 1 - i ] ;
317+ des [ des . Length - 1 - i ] = l ;
318+ }
319+ }
297320 }
298321
299322 return des ;
0 commit comments