Here is something more usable in C# :
Code:
Index: AviSynthAudioEncoder.cs
===================================================================
--- AviSynthAudioEncoder.cs (revision 570)
+++ AviSynthAudioEncoder.cs (working copy)
@@ -552,6 +552,46 @@
script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
break;
case ".wav":
+ FileStream fs = new FileStream(audioJob.Input, FileMode.Open, FileAccess.ReadWrite);
+ fs.Seek(20, SeekOrigin.Begin); // AudioFormat offset
+ byte[] aux = new byte[4]; // only a byte buffer
+
+ fs.Read(aux, 1, 2);
+ UInt16 AudioFormat = (UInt16)(((aux)[0] & 0xff) | ((aux)[1] << 8)); // Or something to read a LE int_16
+
+
+ switch (AudioFormat)
+ {
+
+ case 0x0001: // PCM Format Int
+ fs.Seek(44, SeekOrigin.Current); // DtsHeader offset
+
+ fs.Read(aux, 1, 4);
+ UInt32 DtsHeader = (UInt32)(((aux)[0] & 0xff) | ((aux)[1] << 8) | ((aux)[2] << 16) | ((aux)[3] << 24)); // Or something to read a LE int_32
+
+ if (DtsHeader == 0xE8001FFF)
+ {
+ script.AppendFormat("NicDtsSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+ break;
+ }
+ break;
+ case 0x0003: // IEEE Float
+ case 0xFFFE: // WAVE_FORMAT_EXTENSIBLE header
+ script.AppendFormat("RaWavSource(\"{0}\", 2){1}", audioJob.Input, Environment.NewLine);
+ break;
+ case 0x0055: // MPEG Layer 3
+ script.AppendFormat("NicMPG123Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+ break;
+ case 0x2000: // AC3
+ script.AppendFormat("NicAc3Source(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+ break;
+ default:
+ script.AppendFormat("WavSource(\"{0}\"){1}", audioJob.Input, Environment.NewLine);
+ break;
+ }
+
+ fs.Close();
+ break;
case ".w64":
case ".aif":
case ".au":
edit: doesn't seem to work correctly. WavSource(...) is always returned. Tested with MP3 & AC3...