예제 #1
0
        private void listBoxAcmDrivers_DoubleClick(object sender, EventArgs e)
        {
            AcmDriver            driver            = listBoxAcmDrivers.SelectedItem as AcmDriver;
            AcmDriverDetailsForm driverDetailsForm = new AcmDriverDetailsForm(driver);

            driverDetailsForm.ShowDialog();
        }
        public void CanConvertImeAdpcmToPcm()
        {
            AcmDriver driver = AcmDriver.FindByShortName("Microsoft IMA ADPCM");

            driver.Open();
            try
            {
                foreach (AcmFormatTag formatTag in driver.FormatTags)
                {
                    foreach (AcmFormat format in driver.GetFormats(formatTag))
                    {
                        if (format.FormatTag == WaveFormatEncoding.DviAdpcm ||
                            format.FormatTag == WaveFormatEncoding.ImaAdpcm)
                        {
                            // see if we can convert it to 16 bit PCM
                            Debug.WriteLine(String.Format("Converting {0} to PCM", format.WaveFormat));
                            CanCreateConversionStream(format.WaveFormat,
                                                      new WaveFormat(format.WaveFormat.SampleRate, 16, format.WaveFormat.Channels));
                        }
                    }
                }
            }
            finally
            {
                driver.Close();
            }
        }
예제 #3
0
 public AcmDriverDetailsForm(AcmDriver driver)
 {
     InitializeComponent();
     AddLine("Long Name: {0}", driver.LongName);
     AddLine("Short Name: {0}", driver.ShortName);
     AddLine("Driver ID: {0}", driver.DriverId);
     driver.Open();
     AddLine("FormatTags:", driver.FormatTags);
     foreach (AcmFormatTag formatTag in driver.FormatTags)
     {
         AddLine("{0}: {1}", formatTag.FormatTagIndex, formatTag.FormatDescription);
         AddLine("   Standard Format Count: {0}", formatTag.StandardFormatsCount);
         AddLine("   Support Flags: {0}", formatTag.SupportFlags);
         AddLine("   Format Tag: {0}, Format Size: {1}", formatTag.FormatTag, formatTag.FormatSize);
         AddLine("   Formats:");
         foreach (AcmFormat format in driver.GetFormats(formatTag))
         {
             AddLine("   {0}: {1}", format.FormatIndex, format.FormatDescription);
             AddLine("      FormatTag: {0}, Support Flags: {1}", format.FormatTag, format.SupportFlags);
             AddLine("      WaveFormat: {0} {1}Hz {2} Channels {3} bits, Block Align: {4}, AverageBytesPerSecond: {5}, Extra Size: {6}",
                     format.WaveFormat.Encoding, format.WaveFormat.SampleRate, format.WaveFormat.Channels,
                     format.WaveFormat.BitsPerSample, format.WaveFormat.BlockAlign, format.WaveFormat.AverageBytesPerSecond,
                     format.WaveFormat.ExtraSize);
         }
     }
     driver.Close();
 }
예제 #4
0
 private static void DescribeAcmDriver(AcmDriver driver, StringBuilder builder)
 {
     builder.AppendFormat("Long Name: {0}\r\n", driver.LongName);
     builder.AppendFormat("Short Name: {0}\r\n", driver.ShortName);
     builder.AppendFormat("Driver ID: {0}\r\n", driver.DriverId);
     builder.AppendFormat("FormatTags:\r\n");
 }
예제 #5
0
 private void AcmForm_Load(object sender, EventArgs e)
 {
     foreach (AcmDriver driver in AcmDriver.EnumerateAcmDrivers())
     {
         listBoxAcmDrivers.Items.Add(driver);
     }
 }
예제 #6
0
 private void RefreshDriversList()
 {
     listBoxAcmDrivers.Items.Clear();
     foreach (var driver in AcmDriver.EnumerateAcmDrivers())
     {
         listBoxAcmDrivers.Items.Add(driver);
     }
 }
예제 #7
0
        public void CanOpenAndCloseDriver()
        {
            IEnumerable <AcmDriver> drivers = AcmDriver.EnumerateAcmDrivers();

            Assert.IsNotNull(drivers);
            foreach (AcmDriver driver in drivers)
            {
                driver.Open();
                driver.Close();
            }
        }
예제 #8
0
        public void CanEnumerateDrivers()
        {
            IEnumerable <AcmDriver> drivers = AcmDriver.EnumerateAcmDrivers();

            Assert.IsNotNull(drivers);
            foreach (AcmDriver driver in drivers)
            {
                Assert.GreaterOrEqual((int)driver.DriverId, 0);
                Assert.IsTrue(!String.IsNullOrEmpty(driver.ShortName));
                Debug.WriteLine(driver.LongName);
            }
        }
예제 #9
0
        private WaveFormat GetTargetFormat(WaveFormat inputFormat)
        {
            WaveFormat outputFormat;
            string     formatDescription;
            string     formatTagDescription;

            AcmDriver.ShowFormatChooseDialog(
                this.Handle,
                "Select Compressed Format:",
                AcmFormatEnumFlags.Convert,
                inputFormat,
                out outputFormat,
                out formatDescription,
                out formatTagDescription);
            return(outputFormat);

            /*
             * if (radioButtonMuLaw.Checked)
             * {
             *  return WaveFormat.CreateCustomFormat(
             *      WaveFormatEncoding.MuLaw,
             *      inputFormat.Channels,
             *      inputFormat.SampleRate,
             *      inputFormat.SampleRate * inputFormat.Channels,
             *      1, 8);
             * }
             * else if (radioButtonALaw.Checked)
             * {
             *  return WaveFormat.CreateCustomFormat(
             *      WaveFormatEncoding.ALaw,
             *      inputFormat.Channels,
             *      inputFormat.SampleRate,
             *      inputFormat.SampleRate * inputFormat.Channels,
             *      1, 8);
             * }
             * else if (radioButtonGsm610.Checked)
             * {
             *  return WaveFormat.CreateCustomFormat(
             *      WaveFormatEncoding.Gsm610,
             *      1,
             *      8000,
             *      1625,
             *      65, 0);
             * }
             * else if (radioButtonAdpcm.Checked)
             * {
             *  return new WaveFormatAdpcm(8000, 1);
             * }
             * throw new NotImplementedException("Not implemented yet!");
             */
        }
예제 #10
0
 private string DescribeCodec(AcmDriver driver)
 {
     try
     {
         StringBuilder builder = new StringBuilder();
         builder.AppendFormat("Long Name: {0}\r\n", driver.LongName);
         builder.AppendFormat("Short Name: {0}\r\n", driver.ShortName);
         builder.AppendFormat("Driver ID: {0}\r\n", driver.DriverId);
         driver.Open();
         builder.AppendFormat("FormatTags:\r\n");
         foreach (AcmFormatTag formatTag in driver.FormatTags)
         {
             builder.AppendFormat("===========================================\r\n");
             builder.AppendFormat("Format Tag {0}: {1}\r\n", formatTag.FormatTagIndex, formatTag.FormatDescription);
             builder.AppendFormat("   Standard Format Count: {0}\r\n", formatTag.StandardFormatsCount);
             builder.AppendFormat("   Support Flags: {0}\r\n", formatTag.SupportFlags);
             builder.AppendFormat("   Format Tag: {0}, Format Size: {1}\r\n", formatTag.FormatTag, formatTag.FormatSize);
             builder.AppendFormat("   Formats:\r\n");
             foreach (AcmFormat format in driver.GetFormats(formatTag))
             {
                 builder.AppendFormat("   ===========================================\r\n");
                 builder.AppendFormat("   Format {0}: {1}\r\n", format.FormatIndex, format.FormatDescription);
                 builder.AppendFormat("      FormatTag: {0}, Support Flags: {1}\r\n", format.FormatTag, format.SupportFlags);
                 builder.AppendFormat("      WaveFormat: {0} {1}Hz Channels: {2} Bits: {3} Block Align: {4}, AverageBytesPerSecond: {5} ({6:0.0} kbps), Extra Size: {7}\r\n",
                                      format.WaveFormat.Encoding, format.WaveFormat.SampleRate, format.WaveFormat.Channels,
                                      format.WaveFormat.BitsPerSample, format.WaveFormat.BlockAlign, format.WaveFormat.AverageBytesPerSecond,
                                      (format.WaveFormat.AverageBytesPerSecond * 8) / 1000.0,
                                      format.WaveFormat.ExtraSize);
                 if (format.WaveFormat is WaveFormatExtraData && format.WaveFormat.ExtraSize > 0)
                 {
                     WaveFormatExtraData wfed = (WaveFormatExtraData)format.WaveFormat;
                     builder.Append("      Extra Bytes:\r\n      ");
                     for (int n = 0; n < format.WaveFormat.ExtraSize; n++)
                     {
                         builder.AppendFormat("{0:X2} ", wfed.ExtraData[n]);
                     }
                     builder.Append("\r\n");
                 }
             }
         }
         driver.Close();
         return(builder.ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #11
0
        private void buttonChooseFormat_Click(object sender, EventArgs e)
        {
            WaveFormat selectedFormat;
            string     selectedFormatDescription;
            string     selectedFormatTagDescription;

            if (AcmDriver.ShowFormatChooseDialog(this.Handle, "Choose a WaveFormat", AcmFormatEnumFlags.None,
                                                 null, out selectedFormat,
                                                 out selectedFormatDescription, out selectedFormatTagDescription))
            {
                MessageBox.Show(String.Format("{0}\r\n{1}\r\n{2}",
                                              selectedFormatDescription,
                                              selectedFormatTagDescription,
                                              selectedFormat));
            }
        }
예제 #12
0
        private WaveFormat GetTargetFormat(WaveFormat inputFormat)
        {
            WaveFormat outputFormat;
            string     formatDescription;
            string     formatTagDescription;

            AcmDriver.ShowFormatChooseDialog(
                Handle,
                "Select Compressed Format:",
                AcmFormatEnumFlags.Convert,
                inputFormat,
                out outputFormat,
                out formatDescription,
                out formatTagDescription);
            return(outputFormat);
        }
예제 #13
0
        private void buttonAdd_Click(object sender, EventArgs args)
        {
            var codecFile = SelectFileToOpen("Select file to open", "ACM Codecs|*.acm;*.dll");

            if (codecFile != null)
            {
                try
                {
                    var driver = AcmDriver.AddLocalDriver(codecFile);
                    listBoxAcmDrivers.Items.Add(driver);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Error Adding Driver", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
예제 #14
0
        /// ------------------------------------------------------------------------------------
        public static WaveFormat GetDefaultWaveFormat(int channels)
        {
            WaveFormat bestFormat = null;

            var pcmDriver = AcmDriver.EnumerateAcmDrivers().SingleOrDefault(d => d.ShortName == "MS-PCM");

            if (pcmDriver != null)
            {
                pcmDriver.Open();

                var formatTag = pcmDriver.FormatTags.SingleOrDefault(t => t.FormatTag == WaveFormatEncoding.Pcm);
                if (formatTag != null)
                {
                    foreach (var fmt in pcmDriver.GetFormats(formatTag))
                    {
                        if (bestFormat == null ||
                            fmt.WaveFormat.BitsPerSample > bestFormat.BitsPerSample ||
                            fmt.WaveFormat.SampleRate > bestFormat.SampleRate)
                        {
                            bestFormat = fmt.WaveFormat;
                        }
                    }
                }
                else
                {
                    var msg = LocalizationManager.GetString("SoundFileUtils.ErrorFindingPcmConversionCapabilitiesMsg",
                                                            "There was an error trying to find PCM audio conversion capabilities on this computer. Ensure that you have a PCM sound driver installed.");

                    ErrorReport.NotifyUserOfProblem(msg);
                }

                pcmDriver.Close();
            }
            else
            {
                var msg = LocalizationManager.GetString("SoundFileUtils.ErrorFindingPcmAudioDriverMsg",
                                                        "There was an error trying to find a PCM audio driver on this computer. Ensure that you have a PCM sound driver installed.");

                ErrorReport.NotifyUserOfProblem(msg);
            }

            return(new WaveFormat(bestFormat.SampleRate, bestFormat.BitsPerSample, channels));
        }
예제 #15
0
 public void CanEnumerateFormatTags()
 {
     foreach (AcmDriver driver in AcmDriver.EnumerateAcmDrivers())
     {
         Debug.WriteLine("Enumerating Format Tags for " + driver.LongName);
         driver.Open();
         IEnumerable <AcmFormatTag> formatTags = driver.FormatTags;
         Assert.IsNotNull(formatTags, "FormatTags");
         foreach (AcmFormatTag formatTag in formatTags)
         {
             Debug.WriteLine(String.Format("{0} {1} {2} Standard formats: {3} Support Flags: {4} Format Size: {5}",
                                           formatTag.FormatTagIndex,
                                           formatTag.FormatTag,
                                           formatTag.FormatDescription,
                                           formatTag.StandardFormatsCount,
                                           formatTag.SupportFlags,
                                           formatTag.FormatSize));
         }
         driver.Close();
     }
 }
예제 #16
0
 public void CanEnumerateFormats()
 {
     using (AcmDriver driver = AcmDriver.FindByShortName("MS-ADPCM"))
     {
         driver.Open();
         IEnumerable <AcmFormatTag> formatTags = driver.FormatTags;
         Assert.IsNotNull(formatTags, "FormatTags");
         foreach (AcmFormatTag formatTag in formatTags)
         {
             IEnumerable <AcmFormat> formats = driver.GetFormats(formatTag);
             Assert.IsNotNull(formats);
             foreach (AcmFormat format in formats)
             {
                 Debug.WriteLine(String.Format("{0} {1} {2} {3} {4}",
                                               format.FormatIndex,
                                               format.FormatTag,
                                               format.FormatDescription,
                                               format.WaveFormat,
                                               format.SupportFlags));
             }
         }
     }
 }
예제 #17
0
 private string DescribeCodec(AcmDriver driver)
 {
     try
     {
         driver.Open();
         var builder = new StringBuilder();
         DescribeAcmDriver(driver, builder);
         foreach (var formatTag in driver.FormatTags)
         {
             DescribeAcmFormatTag(builder, formatTag);
             foreach (var format in driver.GetFormats(formatTag))
             {
                 DescribeAcmFormat(builder, format);
             }
         }
         driver.Close();
         return(builder.ToString());
     }
     catch (Exception e)
     {
         return(e.ToString());
     }
 }
예제 #18
0
 public void HasFindByShortNameMethod()
 {
     AcmDriver driver = AcmDriver.FindByShortName("WM-AUDIO");
 }
예제 #19
0
 public void FindsStandardCodec()
 {
     Assert.IsTrue(AcmDriver.IsCodecInstalled("MS-ADPCM"));
 }
예제 #20
0
 public void DoesntFindNonexistentCodec()
 {
     Assert.IsFalse(AcmDriver.IsCodecInstalled("ASJHASDHJSAK"));
 }
예제 #21
0
        private void listBoxAcmDrivers_SelectedIndexChanged(object sender, EventArgs e)
        {
            AcmDriver driver = listBoxAcmDrivers.SelectedItem as AcmDriver;

            richTextBox1.Text = DescribeCodec(driver);
        }