SiteHeart

New! Alvas.Audio

Our partners
Alvas.Net - .Net developers toolbox
Click here to print this page news RSS feed
  Overview    News    Articles    How to..    Samples    Videos    Order    Free Trial    Demo       PR    PAD  

Samples from Alvas.Audio.chm

1. This example shows simple using of RecordPlayer class.

2. This example shows simple using of VolumeData property.

3. This example shows how simple use AiffWriter.

4. This example shows how simple use AiffReader.

5. This example shows simple using of SoundLevelMeter class.

6. This example shows how simple use Player.

7. This example shows simple using of Play method.

8. This example shows simple using of RawReader.

9. This example shows simple using of Mp3Reader.

10. This example shows simple using of MakeWave method.

11. This example shows simple using of ReadID3v1Tag method.

12. This example shows simple using of WriteID3v1Tag method.

13. This example shows simple using of PlayerEx class.

14. This example shows simple using of GetPlayerName method.

15. This example shows how mixed audio data plays.

16. This example shows simple using of Mp3Writer class.

17. This example shows how simple use CafWriter.

18. This example shows how simple use CafReader.

19. This example shows how simple use Recorder.

20. This example shows simple using of Raw2Vox method.

21. This example shows simple using of Vox2Wav method.

22. This example shows simple using of Vox2Mp3 method.

23. This example shows simple using of Vox2Mp3 method.

24. This example shows simple using of Vox2Mp3 method.

25. This example shows simple using of Mixer class.

26. This example shows simple using of GetMixerName method.

27. This example shows how simple use WaveWriter.

28. This example shows how simple use WaveReader.

29. This example shows simple using of MakeMP3 method.

30. This example shows simple using of ReadInfoTag method.

31. This example shows simple using of RawWriter class.

32. This example shows simple using of CheckSilent method.

33. This example shows simple using of MergeStereo method.

34. This example shows simple using of ChooseCompatibleFormat method.

35. This example shows simple using of ChooseCompatibleFormat method.

36. This example shows simple using of ToPcm method.

37. This example shows simple using of GetCompatibleFormat method.

38. This example shows simple using of Convert method.

39. This example shows simple using of Convert method.

40. This example shows simple using of ChangeSpeed method.

41. This example shows simple using of ChangeSpeed method.

42. This example shows simple using of ChangeSpeed method.

43. This example shows simple using of ChangeVolume method.

44. This example shows simple using of Copy method.

45. This example shows simple using of Copy method.

46. This example shows simple using of Remove method.

47. This example shows simple using of Remove method.

48. This example shows simple using of CreateFormat method.

49. This example shows simple using of FormatBytes method.

50. This example shows simple using of GetFormatTagList method.

51. This example shows simple using of GetFormatList method.

52. This example shows simple using of GetFormatList method for specified driver.

53. This example shows simple using of GetFormatList method.

54. This example shows simple using of GetFormatList method for specified driver.

55. This example shows simple using of GetDriverList method.

56. This example shows simple using of GetFormatDetails method.

57. This example shows simple using of GetFormatDetails method.

58. This example shows simple using of GetFormatTagDetails method.

59. This example shows simple using of GetCompatibleFormatList method.

60. This example shows simple using of GetCompatibleFormatList method.

61. This example shows simple using of Wave2Mp3 method.

62. This example shows simple using of Wave2Mp3 method.

63. This example shows simple using of Mp3ToWav method.

64. This example shows simple using of Wave2Mp3 method.

65. This example shows simple using of Fade method.

66. This example shows simple using of ToPcm16Bit method.

67. This example shows simple using of Silence method.

68. This example shows simple using of Reverse method.

69. This example shows simple using of Reverse method.

70. This example shows simple using of Reverse method.

71. This example shows simple using of SplitStereo method.

72. This example shows simple using of SplitStereo method.

73. This example shows simple using of SplitStereo method.

74. This example shows how translates an audio file in GSM 06.10 (full-rate) lossy speech compression to a WavPack lossless, lossy, and hybrid audio compression file

75. This example shows how translates an audio file in Creative Technology Sound Blaster format to a GSM 06.10 (full-rate) lossy speech compression file

76. This example shows how translates an audio file in Creative Technology Sound Blaster format to a Xiph.org's ogg-vorbis lossy compression file

77. This example shows how translates an audio file in Sun AU format to a Xiph.org's ogg-vorbis lossy compression file

78. This example shows how translates an audio file in Sun AU format to a Microsoft WAV file

79. This example shows simple using of WriteInfoTag method.

80. This example shows simple using of DsReader class.

81. This example shows simple using of RecorderEx class.

82. This example shows simple using of GetRecorderName method.

83. This example shows simple using of AviReader.


1. This example shows simple using of RecordPlayer class.


            public static void TestRecordPlayer()
            {
                RecordPlayer rp = new RecordPlayer();
                rp.PropertyChanged += new PropertyChangedEventHandler(rp_PropertyChanged);
                rp.Open(new Mp3Reader(File.OpenRead("in.mp3")));
                rp.Play();
            }
            
            static void rp_PropertyChanged(object sender, PropertyChangedEventArgs e)
            {
                switch (e.PropertyName)
                {
                    case RecordPlayer.StateProperty:
                        RecordPlayer rp = ((RecordPlayer)sender);
                        if (rp.State == DeviceState.Stopped)
                        {
                            rp.Close();
                        }
                        break;
                }
            }
             

2. This example shows simple using of VolumeData property.


            private void Init()
            {
                slm = new SoundLevelMeter();
                slm.Dock = DockStyle.Fill;
                this.Controls.Add(slm);
                IntPtr pcmFormat = AudioCompressionManager.GetPcmFormat(2, 16, 44100);
                rp.VolumeDataLength = slm.ClientSize.Width;
                rp.PropertyChanged += new PropertyChangedEventHandler(rp_PropertyChanged);
                rp.Open(new WaveReadWriter(new MemoryStream(), AudioCompressionManager.FormatBytes(pcmFormat)));
                rp.Record();
            }
            
            SoundLevelMeter slm;
            RecordPlayer rp = new RecordPlayer();
            
            void rp_PropertyChanged(object sender, PropertyChangedEventArgs e)
            {
                if (e.PropertyName == RecordPlayer.VolumeLevelProperty)
                {
                    slm.Data = rp.VolumeData;
                };
            }
             

3. This example shows how simple use AiffWriter.


            string fileName = "123.aif";
            RecorderEx recEx = new RecorderEx();
            Stream stream = new FileStream(fileName, FileMode.Create);
            AiffWriter aw = new AiffWriter(stream, recEx.Format);
             

4. This example shows how simple use AiffReader.


            AiffReader ar = new AiffReader(File.OpenRead("123.aif"));
            IntPtr format = ar.ReadFormat();
            byte[] data = ar.ReadData();
            ar.Close();
             

5. This example shows simple using of SoundLevelMeter class.


            SoundLevelMeter vum = new SoundLevelMeter();
            WaveReader wr = new WaveReader(File.OpenRead("in.wav"));
            IntPtr format = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
            short[] buffer = AudioCompressionManager.RecalculateData(format, data, vum.ClientRectangle.Width);
            vum.Data = buffer;
             

6. This example shows how simple use Player.


            player.FileName = "123.mp3";
            player.Play();
             

7. This example shows simple using of Play method.


            Player pl = new Player();
            byte[] arr = File.ReadAllBytes(@"in.wav");
            pl.Play(arr);
             

8. This example shows simple using of RawReader.


            WaveFormat wfAlaw = new WaveFormat();
            wfAlaw.wFormatTag = AudioCompressionManager.ALawFormatTag;
            wfAlaw.nChannels = 1;
            wfAlaw.nSamplesPerSec = 8000;
            FormatDetails[] fdArr = AudioCompressionManager.GetFormatList(wfAlaw);
            RawReader rr = new RawReader(File.OpenRead("123.alaw"), 
                fdArr[0].FormatHandle);
            IntPtr format = rr.ReadFormat();
            byte[] data = rr.ReadData();
            rr.Close();
             

9. This example shows simple using of Mp3Reader.


            Mp3Reader mr = new Mp3Reader(File.OpenRead("123.mp3"));
            IntPtr format = mr.ReadFormat();
            byte[] data = mr.ReadData();
            mr.Close();
             

10. This example shows simple using of MakeWave method.


            string mp3File = "in.mp3";
            using (Mp3Reader mr = new Mp3Reader(File.OpenRead(mp3File)))
            {
                string wavFile = "out.wav";
                using (FileStream fs = File.Create(wavFile))
                {
                    mr.MakeWave(fs);
                }
            }
             

11. This example shows simple using of ReadID3v1Tag method.


            Mp3Reader br = new Mp3Reader(File.OpenRead(fileName));
            ID3v1 id3v1 = br.ReadID3v1Tag();
            br.Close();
            if (id3v1 != null)
            {
                Console.WriteLine(id3v1.Title);
            }
             

12. This example shows simple using of WriteID3v1Tag method.


             //removes ID3v1 tags from audio stream 
            Mp3ReadWriter mrw1 = new Mp3ReadWriter(File.Open("in1.mp3", FileMode.Open, FileAccess.ReadWrite));
            mrw1.WriteID3v1Tag(null);
            mrw1.Close();
            
             //writes ID3v1 tags into audio stream 
            Mp3ReadWriter mrw2 = new Mp3ReadWriter(File.Open("in2.mp3", FileMode.Open, FileAccess.ReadWrite));
            ID3v1 tag = new ID3v1();
            tag.Comment = "Comment...";
            mrw2.WriteID3v1Tag(tag);
            mrw2.Close();
             

13. This example shows simple using of PlayerEx class.


            public static void TestPlayerEx()
            {
                PlayerEx plex = new PlayerEx();
                plex.Done += new PlayerEx.DoneEventHandler(plex_Done);
                Mp3Reader mr = new Mp3Reader(File.OpenRead("in.mp3"));
                IntPtr format = mr.ReadFormat();
                byte[] data = mr.ReadData();
                mr.Close();
                plex.OpenPlayer(format);
                plex.AddData(data);
                plex.StartPlay();
            }
            
            static void plex_Done(object sender, DoneEventArgs e)
            {
                if (e.IsEndPlaying)
                {
                    ((PlayerEx)sender).ClosePlayer();
                }
            }
             

14. This example shows simple using of GetPlayerName method.


            for (int i = 0; i < PlayerEx.PlayerCount; i++)
            {
                Console.WriteLine(PlayerEx.GetPlayerName(i));
            }
             

15. This example shows how mixed audio data plays.


            public void PlayMix()
            {
            		string dir = Path.GetDirectoryName(Application.ExecutablePath);
            		string path1 = dir + @"\1.wav";
            		WaveReader wr1 = new WaveReader(File.OpenRead(path1));
            		IntPtr format = wr1.ReadFormat();
            		WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);
            		playEx.OpenPlayer(format);//validFormat
            		byte[] data1 = wr1.ReadData();
            		wr1.Close();
            		//----------
            		string path2 = dir + @"\2.wav";
            		WaveReader wr2 = new WaveReader(File.OpenRead(path2));
            		byte[] data2 = wr2.ReadData();
            		wr2.Close();
            		playEx.AddMixData(data1, data2);
            		playEx.StartPlay();
            }
             

16. This example shows simple using of Mp3Writer class.


            Mp3Writer mw = new Mp3Writer(File.Create("new.mp3"));
            mw.WriteData(dataMp3);
            mw.Close();
             

17. This example shows how simple use CafWriter.


            string fileName = "123.caf";
            RecorderEx recEx = new RecorderEx();
            Stream stream = new FileStream(fileName, FileMode.Create);
            CafWriter cw = new CafWriter(stream, recEx.Format);
             

18. This example shows how simple use CafReader.


            CafReader cr = new CafReader(File.OpenRead("123.caf"));
            IntPtr format = cr.ReadFormat();
            byte[] data = cr.ReadData();
            cr.Close();
             

19. This example shows how simple use Recorder.


            rec.Open();
            Recorder.Channel rc = Recorder.Channel.Stereo;
            Recorder.BitsPerSample rbps = Recorder.BitsPerSample.Bps16;
            Recorder.SamplesPerSec rsps = Recorder.SamplesPerSec.Sps8000;
            rec.Configure(rc, rbps, rsps);
            rec.Record();
             

20. This example shows simple using of Raw2Vox method.


            private static void Decode2Pcm(ref IntPtr format, ref byte[] data, ref WaveFormat wf)
            {
                IntPtr newFormat = AudioCompressionManager.GetCompatibleFormat(format, AudioCompressionManager.PcmFormatTag);
                byte[] buffer = AudioCompressionManager.Convert(format, newFormat, data, false);
                wf = AudioCompressionManager.GetWaveFormat(newFormat);
                format = newFormat;
                data = buffer;
            }
            
            public static void Raw2VoxTest()
            {
                string inFile = "in.wav";
                string outFile = "out.vox";
                WaveReader wr = new WaveReader(File.OpenRead(inFile));
                IntPtr format = wr.ReadFormat();
                byte[] data = wr.ReadData();
                wr.Close();
                WaveFormat wf = AudioCompressionManager.GetWaveFormat(format);
                if (wf.wFormatTag != AudioCompressionManager.PcmFormatTag)//Decode if not PCM data 
                {
                    Decode2Pcm(ref format, ref data, ref wf);
                }
                BinaryWriter bw = new BinaryWriter(File.OpenWrite(outFile));
                BinaryReader br = new BinaryReader(new MemoryStream(data));
                Vox.Raw2Vox(br, bw, wf.wBitsPerSample);
                br.Close();
                bw.Close();
            }
             

21. This example shows simple using of Vox2Wav method.


            string voxFile = "in.vox";
            int samplesPerSec = 8000;
            string wavFile = "out.wav";
            BinaryReader br = new BinaryReader(File.OpenRead(voxFile));
            IntPtr format = AudioCompressionManager.GetPcmFormat(1, 16, samplesPerSec);
            WaveWriter ww = new WaveWriter(File.Create(wavFile), AudioCompressionManager.FormatBytes(format));
            Vox.Vox2Wav(br, ww);
            br.Close();
            ww.Close();
             

22. This example shows simple using of Vox2Mp3 method.


            string voxFile = "in.vox";
            string mp3File = "out.mp3";
            int samplesPerSec = 8000;
            Vox.Vox2Mp3(voxFile, mp3File, samplesPerSec);
             

23. This example shows simple using of Vox2Mp3 method.


            string voxFile = "in.vox";
            string mp3File = "out.mp3";
            int samplesPerSec = 8000;
            Vox.Vox2Mp3(File.OpenRead(voxFile), File.Create(mp3File), samplesPerSec);
             

24. This example shows simple using of Vox2Mp3 method.


            string voxFile = "in.vox";
            string mp3File = "out.mp3";
            int samplesPerSec = 8000;
            BinaryReader br = new BinaryReader(File.OpenRead(voxFile));
            Mp3Writer mw = new Mp3Writer(File.Create(mp3File));
            Vox.Vox2Mp3(br, mw, samplesPerSec);
            mw.Close();
            br.Close();
             

25. This example shows simple using of Mixer class.


            public static void TestMixer()
            {
                PlayerEx plex = new PlayerEx();
                int playerMixerNo = plex.GetMixerNo();
                bool isMute = GetPlayerMute(playerMixerNo);
                SetPlayerMute(playerMixerNo, !isMute);
            
                RecorderEx rex = new RecorderEx();
                SetRecorderVolumeMax(rex.GetMixerNo());
            }
            
            private static void SetRecorderVolumeMax(int recorderMixerNo)
            {
                Mixer mx = new Mixer();
                mx.MixerNo = recorderMixerNo;
                DestinationLine dl = mx.GetDestination(Mixer.Recording);
                if (dl != null)
                {
                    foreach (MixerControl mc in dl.Controls)
                    {
                        if (mc is MixerIntControl)
                        {
                            MixerIntControl mic = mc as MixerIntControl;
                            mic.Value = mic.Maximum;
                            break;
                        }
                        else if (mc is MixerListControl)
                        {
                            MixerListControl mlc = dl.Controls[0] as MixerListControl;
                            MixerLine ml = mlc.Lines[mlc.Value];
                            foreach (MixerControl ctrl in ml.Controls)
                            {
                                if (ctrl is MixerIntControl)
                                {
                                    MixerIntControl mic = ctrl as MixerIntControl;
                                    mic.Value = mic.Maximum;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
            
            private static bool GetPlayerMute(int playerMixerNo)
            {
                Mixer mx = new Mixer();
                mx.MixerNo = playerMixerNo;
                DestinationLine dl = mx.GetDestination(Mixer.Playback);
                if (dl != null)
                {
                    foreach (MixerControl ctrl in dl.Controls)
                    {
                        if (ctrl is MixerMuteControl)
                        {
                            return ((MixerMuteControl)ctrl).Value != 0;
                        }
                    }
                }
                return false;
            }
            
            private static void SetPlayerMute(int playerMixerNo, bool value)
            {
                Mixer mx = new Mixer();
                mx.MixerNo = playerMixerNo;
                DestinationLine dl = mx.GetDestination(Mixer.Playback);
                if (dl != null)
                {
                    foreach (MixerControl ctrl in dl.Controls)
                    {
                        if (ctrl is MixerMuteControl)
                        {
                            ((MixerMuteControl)ctrl).Value = (value) ? 1 : 0;
                            break;
                        }
                    }
                }
            }
             

26. This example shows simple using of GetMixerName method.


            for (int i = 0; i < Mixer.MixerCount; i++)
            {
               Console.WriteLine(Mixer.GetMixerName(i));
            }
            

27. This example shows how simple use WaveWriter.


            string fileName = "123.wav";
            RecorderEx recEx = new RecorderEx();
            Stream stream = new FileStream(fileName, FileMode.Create);
            WaveWriter wr = new WaveWriter(stream, recEx.FormatBytes());
             

28. This example shows how simple use WaveReader.


            WaveReader wr = new WaveReader(File.OpenRead("123.wav"));
            IntPtr format = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
             

29. This example shows simple using of MakeMP3 method.


            string wavFile = "in.wav";
            using (WaveReader wr = new WaveReader(File.OpenRead(wavFile)))
            {
                string mp3File = "out.mp3";
                using (FileStream fs = File.Create(mp3File))
                {
                    wr.MakeMP3(fs);
                }
            }
             

30. This example shows simple using of ReadInfoTag method.


            WaveReader br = new WaveReader(File.OpenRead(fileName));
            var dir = br.ReadInfoTag();
            br.Close();
            if (dir.Count > 0)
            {
                foreach (string val in dir.Values)
                {
                    Console.WriteLine(val);
                }
            }
             

31. This example shows simple using of RawWriter class.


            RawWriter rw = new RawWriter(File.Create("out.pcm"));
            rw.WriteData(new byte[16000]);
            rw.Close();
             

32. This example shows simple using of CheckSilent method.


            private static void SkipSilent(string fileName, short silentLevel)
            {
                WaveReader wr = new WaveReader(File.OpenRead(fileName));
                IntPtr format = wr.ReadFormat();
                WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), AudioCompressionManager.FormatBytes(format));
                int i = 0;
                while (true)
                {
                    byte[] data = wr.ReadData(i, 1);
                    if (data.Length == 0)
                    {
                        break;
                    }
                    if (!AudioCompressionManager.CheckSilent(format, data, silentLevel))
                    {
                        ww.WriteData(data);
                    }
                }
                ww.Close();
                wr.Close();
            }
             

33. This example shows simple using of MergeStereo method.


            AudioCompressionManager.MergeStereo(@"Left.wav", @"Right.wav", @"res.wav");
            

34. This example shows simple using of ChooseCompatibleFormat method.


            IntPtr formatOld = AudioCompressionManager.GetPcmFormat(1, 16, 44100);
            FormatChooseResult fcr = AudioCompressionManager.ChooseCompatibleFormat(IntPtr.Zero, formatOld);
            if (fcr.Result == 0)
            {
                Console.WriteLine("{0} {1}", fcr.FormatTagName, fcr.FormatName);
                IntPtr format = fcr.Format;
            }
             

35. This example shows simple using of ChooseCompatibleFormat method.


            IntPtr formatOld = AudioCompressionManager.GetPcmFormat(1, 16, 44100);
            FormatChooseResult fcr = AudioCompressionManager.ChooseCompatibleFormat(IntPtr.Zero, formatOld, "Select Audio Format");
            if (fcr.Result == 0)
            {
                Console.WriteLine("{0} {1}", fcr.FormatTagName, fcr.FormatName);
                IntPtr format = fcr.Format;
            }
             

36. This example shows simple using of ToPcm method.


            string fileName = @"in.wav";
            WaveReader wr = new WaveReader(File.OpenRead(fileName));
            IntPtr formatWav = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
            IntPtr formatPcm = IntPtr.Zero;
            byte[] dataPcm = null;
            AudioCompressionManager.ToPcm(formatWav, data, ref formatPcm, ref dataPcm);
            WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), AudioCompressionManager.FormatBytes(formatPcm));
            ww.WriteData(dataPcm);
            ww.Close();
             

37. This example shows simple using of GetCompatibleFormat method.


            IntPtr formaGsm = AudioCompressionManager.GetCompatibleFormat(AudioCompressionManager.GetPcmFormat(1, 16, 16000),
                            AudioCompressionManager.Gsm610FormatTag);
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(formaGsm, true);
            Console.WriteLine(fd.ToString());
             

38. This example shows simple using of Convert method.


            Mp3Reader mr = new Mp3Reader(File.OpenRead("in.mp3"));
            IntPtr formatMp3 = mr.ReadFormat();
            IntPtr formatPcm = AudioCompressionManager.GetCompatibleFormat(formatMp3, 
                AudioCompressionManager.PcmFormatTag);
            WaveWriter ww = new WaveWriter(File.Create("out.wav"), 
                AudioCompressionManager.FormatBytes(formatPcm));
            AudioCompressionManager.Convert(mr, ww, false);
            mr.Close();
            ww.Close();
             

39. This example shows simple using of Convert method.


            Mp3Reader mr = new Mp3Reader(File.OpenRead("in.mp3"));
            IntPtr formatMp3 = mr.ReadFormat();
            byte[] dataMp3 = mr.ReadData();
            mr.Close();
            IntPtr formatPcm = AudioCompressionManager.GetCompatibleFormat(formatMp3,
                AudioCompressionManager.PcmFormatTag);
            byte[] dataPcm = AudioCompressionManager.Convert(formatMp3, formatPcm, dataMp3, false);
            WaveWriter ww = new WaveWriter(File.Create("out.wav"),
                AudioCompressionManager.FormatBytes(formatPcm));
            ww.WriteData(dataPcm);
            ww.Close();
             

40. This example shows simple using of ChangeSpeed method.


            string inFile = @"in.wav";
            string outFile = @"out.wav";
            int persent = 50;
            AudioCompressionManager.ChangeSpeed(inFile, outFile, persent);
             

41. This example shows simple using of ChangeSpeed method.


            string inFile = @"in.wav";
            string outFile = @"out.wav";
            int persent = 50;
            AudioCompressionManager.ChangeSpeed(File.OpenRead(inFile), File.Create(outFile), persent);
             

42. This example shows simple using of ChangeSpeed method.


            string inFile = @"in.mp3";
            string outFile = @"out.mp3";
            int persent = 50;
            Mp3Reader mr = new Mp3Reader(File.OpenRead(inFile));
            IntPtr format = mr.ReadFormat();
            byte[] data = mr.ReadData();
            mr.Close();
            byte[] outData = AudioCompressionManager.ChangeSpeed(format, data, persent);
            Mp3Writer mw = new Mp3Writer(File.Create(outFile));
            mw.WriteData(outData);
            mw.Close();
             

43. This example shows simple using of ChangeVolume method.


            string inFile = @"in.mp3";
            string outFile = @"out.mp3";
            int persent = 50;
            Mp3Reader mr = new Mp3Reader(File.OpenRead(inFile));
            IntPtr format = mr.ReadFormat();
            byte[] data = mr.ReadData();
            mr.Close();
            byte[] outData = AudioCompressionManager.ChangeVolume(format, data, persent);
            Mp3Writer mw = new Mp3Writer(File.Create(outFile));
            mw.WriteData(outData);
            mw.Close();
             

44. This example shows simple using of Copy method.


            string inFile = "in.wav";
            string outFile = "out.wav";
            int skipSeconds = 1;
            int readSeconds = 2;
            AudioCompressionManager.Copy(inFile, outFile, skipSeconds, readSeconds);
             

45. This example shows simple using of Copy method.


            string inFile = "in.wav";
            string outFile = "out.wav";
            int skipSeconds = 1;
            int readSeconds = 2;
            AudioCompressionManager.Copy(File.OpenRead(inFile), File.Create(outFile), skipSeconds, readSeconds);
             

46. This example shows simple using of Remove method.


            string inFile = "in.wav"; 
            string outFile = "out.wav"; 
            int fromSeconds = 0;
            int duration = 1;
            AudioCompressionManager.Remove(File.OpenRead(inFile), File.Create(outFile), fromSeconds, duration);
             

47. This example shows simple using of Remove method.


            string inFile = "in.wav"; 
            string outFile = "out.wav"; 
            int fromSeconds = 0;
            int duration = 1;
            AudioCompressionManager.Remove(inFile, outFile, fromSeconds, duration);
             

48. This example shows simple using of CreateFormat method.


            IntPtr format = AudioCompressionManager.CreateFormat(AudioCompressionManager.FormatBytes(AudioCompressionManager.GetPcmFormat(2, 16, 8000)));
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(format, true);
            Console.WriteLine(fd.ToString());
             

49. This example shows simple using of FormatBytes method.


            WaveWriter ww = new WaveWriter(File.Create("out.wav"), 
                AudioCompressionManager.FormatBytes(AudioCompressionManager.GetPcmFormat(2, 16, 8000)));
            ww.Close();
             

50. This example shows simple using of GetFormatTagList method.


            FormatTagDetails ftd = AudioCompressionManager.GetFormatTagDetails(AudioCompressionManager.PcmFormatTag);
            Console.WriteLine(ftd.FormatTagName);
             

51. This example shows simple using of GetFormatList method.


            FormatDetails[] fdArr = AudioCompressionManager.GetFormatList(AudioCompressionManager.ImaAdpcmFormatTag);
            foreach (FormatDetails fd in fdArr)
            {
                Console.WriteLine(fd.ToString());
            }
             

52. This example shows simple using of GetFormatList method for specified driver.


            private void GetDriver()
            {
                foreach (DriverDetails dd in AudioCompressionManager.GetDriverList())
                {
                    if (dd.LongName.Contains("{insert text here}"))
                    {
                        int driverId = dd.Driver;
                        FormatDetails[] fd = AudioCompressionManager.GetFormatList(AudioCompressionManager.MpegLayer3FormatTag, driverId);
                        break;
                    }
                };
            }
             

53. This example shows simple using of GetFormatList method.


            FormatDetails[] fdArr = AudioCompressionManager.GetFormatList(AudioCompressionManager.AdpcmFormatTag, true);
            foreach (FormatDetails fd in fdArr)
            {
                Console.WriteLine(fd.ToString());
            }
             

54. This example shows simple using of GetFormatList method for specified driver.


            private void GetDriver()
            {
                foreach (DriverDetails dd in AudioCompressionManager.GetDriverList())
                {
                    if (dd.LongName.Contains("{insert text here}"))
                    {
                        int driverId = dd.Driver;
                        FormatDetails[] fd = AudioCompressionManager.GetFormatList(AudioCompressionManager.MpegLayer3FormatTag, driverId, true);
                        break;
                    }
                };
            }
             

55. This example shows simple using of GetDriverList method.


            DriverDetails[] driverList = AudioCompressionManager.GetDriverList();
            
            foreach (DriverDetails driverDetails in driverList)
            {
                Console.WriteLine("Driver: {0}, Version: {1}, LongName: {2}", driverDetails.Driver, driverDetails.DriverVersion, driverDetails.LongName);
            }
             

56. This example shows simple using of GetFormatDetails method.


            IntPtr format = AudioCompressionManager.GetPcmFormat(2, 16, 24000);
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(format);
            Console.WriteLine(fd.ToString());
             

57. This example shows simple using of GetFormatDetails method.


            IntPtr format = AudioCompressionManager.GetPcmFormat(2, 16, 24000);
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(format, true);
            Console.WriteLine(fd.ToString());
             

58. This example shows simple using of GetFormatTagDetails method.


            FormatTagDetails ftd = AudioCompressionManager.GetFormatTagDetails(AudioCompressionManager.PcmFormatTag);
            Console.WriteLine(ftd.FormatTagName);
             

59. This example shows simple using of GetCompatibleFormatList method.


            IntPtr formaGsm = AudioCompressionManager.GetCompatibleFormat(AudioCompressionManager.GetPcmFormat(1, 16, 16000),
                            AudioCompressionManager.Gsm610FormatTag);
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(formaGsm);
            Console.WriteLine(fd.ToString());
             

60. This example shows simple using of GetCompatibleFormatList method.


            IntPtr formaGsm = AudioCompressionManager.GetCompatibleFormat(AudioCompressionManager.GetPcmFormat(1, 16, 16000),
                            AudioCompressionManager.Gsm610FormatTag);
            FormatDetails fd = AudioCompressionManager.GetFormatDetails(formaGsm, true);
            Console.WriteLine(fd.ToString());
             

61. This example shows simple using of Wave2Mp3 method.


            string inFile = "test2.wav";
            string outFile = @"test2.mp3";
            
            AudioCompressionManager.Wave2Mp3(inFile, outFile);
             

62. This example shows simple using of Wave2Mp3 method.


            string inFile = "test2.wav";
            string outFile = @"test2.mp3";
            
            AudioCompressionManager.Wave2Mp3(File.OpenRead(inFile), File.Create(outFile));
             

63. This example shows simple using of Mp3ToWav method.


            AudioCompressionManager.Mp3ToWav("in.mp3", "out.wav");
             

64. This example shows simple using of Wave2Mp3 method.


            string inFile = "test2.wav";
            string outFile = @"test2.mp3";
            
            WaveReader wr = new WaveReader(File.OpenRead(inFile));
            IntPtr format = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
            byte[] dataMp3 = AudioCompressionManager.Wave2Mp3(format, data);
            Mp3Writer mw = new Mp3Writer(File.Create(outFile));
            mw.WriteData(dataMp3);
            mw.Close();
             

65. This example shows simple using of Fade method.


            WaveReader wr = new WaveReader(File.OpenRead("in.wav"));
            IntPtr format = wr.ReadFormat();
            byte[] data1 = wr.ReadData(0, 1);
            byte[] data2 = wr.ReadData(1, 1);
            byte[] data3 = wr.ReadData(2, 1);
            wr.Close();
            byte[] data11 = AudioCompressionManager.Fade(format, data1, true);
            byte[] data33 = AudioCompressionManager.Fade(format, data3, false);
            WaveWriter ww = new WaveWriter(File.Create("out.wav"), AudioCompressionManager.FormatBytes(format));
            ww.WriteData(data11);
            ww.WriteData(data2);
            ww.WriteData(data33);
            ww.Close();
             

66. This example shows simple using of ToPcm16Bit method.


            string fileName = @"in.wav";
            WaveReader wr = new WaveReader(File.OpenRead(fileName));
            IntPtr formatWav = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
            IntPtr formatPcm = IntPtr.Zero;
            byte[] dataPcm = null;
            AudioCompressionManager.ToPcm(formatWav, data, ref formatPcm, ref dataPcm);
            WaveWriter ww = new WaveWriter(File.Create(fileName + ".wav"), AudioCompressionManager.FormatBytes(formatPcm));
            ww.WriteData(dataPcm);
            ww.Close();
             

67. This example shows simple using of Silence method.


            FormatDetails[] formatList = AudioCompressionManager.GetFormatList(AudioCompressionManager.Gsm610FormatTag);
            IntPtr format = formatList[formatList.Length - 1].FormatHandle;
            WaveWriter ww = new WaveWriter(File.Create("file.wav"), AudioCompressionManager.FormatBytes(format));
            byte[] data = AudioCompressionManager.Silence(format, 10000);
            ww.WriteData(data);
            ww.Close();
             

68. This example shows simple using of Reverse method.


            string inFile = "test2.wav";
            string outFile = "ReverseTest3.wav";
            
            AudioCompressionManager.Reverse(inFile, outFile);
             

69. This example shows simple using of Reverse method.


            string inFile = "test2.wav";
            string outFile = "ReverseTest3.wav";
            
            AudioCompressionManager.Reverse(File.OpenRead(inFile), File.Create(outFile));
             

70. This example shows simple using of Reverse method.


            string inFile = "test2.wav";
            string outFile = "ReverseTest3.wav";
            
            WaveReader wr = new WaveReader(File.OpenRead(inFile));
            IntPtr format = wr.ReadFormat();
            byte[] data = wr.ReadData();
            wr.Close();
            WaveWriter ww = new WaveWriter(File.Create(outFile), AudioCompressionManager.FormatBytes(format));
            ww.WriteData(AudioCompressionManager.Reverse(format, data));
            ww.Close();
             

71. This example shows simple using of SplitStereo method.


            string inFile = "stereo.wav";
            string leftFile = "left.wav";
            string rightFile = "right.wav";
            AudioCompressionManager.SplitStereo(inFile, leftFile, rightFile);
             

72. This example shows simple using of SplitStereo method.


            string inFile = "stereo.wav";
            string leftFile = "left.wav";
            string rightFile = "right.wav";
            AudioCompressionManager.SplitStereo(File.OpenRead(inFile), 
                File.Create(leftFile), File.Create(rightFile));
             

73. This example shows simple using of SplitStereo method.


            string inFile = "stereo.wav";
            string leftFile = "left.wav";
            string rightFile = "right.wav";
            WaveReader wr = new WaveReader(File.OpenRead(inFile));
            IntPtr formatStereo = wr.ReadFormat();
            byte[] dataStereo = wr.ReadData();
            wr.Close();
            IntPtr formatMono = IntPtr.Zero;
            byte[] leftData = null;
            byte[] rightData = null;
            AudioCompressionManager.SplitStereo(formatStereo, dataStereo, ref formatMono, ref leftData, ref rightData);
            byte[] headerMono = AudioCompressionManager.FormatBytes(formatMono);
            WaveWriter wwLeft = new WaveWriter(File.Create(leftFile), headerMono);
            wwLeft.WriteData(leftData);
            wwLeft.Close();
            WaveWriter wwRight = new WaveWriter(File.Create(rightFile), headerMono);
            wwRight.WriteData(rightData);
            wwRight.Close();
             

74. This example shows how translates an audio file in GSM 06.10 (full-rate) lossy speech compression to a WavPack lossless, lossy, and hybrid audio compression file


            try
            {
            using (BinaryWriter to = new BinaryWriter(File.Create("Output.wv")))
            {
                Sox.Convert("sox.exe", "input.gsm", SoxAudioFileType.Gsm, to, SoxAudioFileType.Wv);
            }
            }
            catch (SoxException e)
            {
                Console.WriteLine("{0}: {1}", e.Code, e.Message);
            }
             

75. This example shows how translates an audio file in Creative Technology Sound Blaster format to a GSM 06.10 (full-rate) lossy speech compression file


            try
            {
            using (BinaryWriter to = new BinaryWriter(File.Create("Output.gsm")))
            {
                Sox.Convert("sox.exe", "input.voc", to, SoxAudioFileType.Gsm);
            }
            }
            catch (SoxException e)
            {
                Console.WriteLine("{0}: {1}", e.Code, e.Message);
            }
             

76. This example shows how translates an audio file in Creative Technology Sound Blaster format to a Xiph.org's ogg-vorbis lossy compression file


            try
            {
                Sox.Convert("sox.exe", "input.voc", SoxAudioFileType.Voc, "output.ogg", SoxAudioFileType.Ogg);
            }
            catch (SoxException e)
            {
                Console.WriteLine("{0}: {1}", e.Code, e.Message);
            }
             

77. This example shows how translates an audio file in Sun AU format to a Xiph.org's ogg-vorbis lossy compression file


            try
            {
                Sox.Convert("sox.exe", "input.au", "output.ogg", SoxAudioFileType.Ogg);
            }
            catch (SoxException e)
            {
                Console.WriteLine("{0}: {1}", e.Code, e.Message);
            }
             

78. This example shows how translates an audio file in Sun AU format to a Microsoft WAV file


            try
            {
                Sox.Convert("sox.exe", "input.au", "output.wav");
            }
            catch (SoxException e)
            {
                Console.WriteLine("{0}: {1}", e.Code, e.Message);
            }
             

79. This example shows simple using of WriteInfoTag method.


             //removes INFO tags from audio stream 
            WaveReadWriter wrw1 = new WaveReadWriter(File.Open("in1.wav", FileMode.Open, FileAccess.ReadWrite));
            wrw1.WriteInfoTag(null);
            wrw1.Close();
            
             //writes INFO tags into audio stream 
            WaveReadWriter wrw2 = new WaveReadWriter(File.Open("in2.wav", FileMode.Open, FileAccess.ReadWrite));
            var tag = new Dictionary();
            tag[WaveInfo.Comments] = "Comments...";
            wrw2.WriteInfoTag(tag);
            wrw2.Close();
             

80. This example shows simple using of DsReader class.


            DsReader dr = new DsReader("in.wma");
            if (dr.HasAudio)
            {
                IntPtr format = dr.ReadFormat();
                byte[] data = dr.ReadData();
            }
            dr.Close();
             

81. This example shows simple using of RecorderEx class.


            public static void TestRecorderEx()
            {
                RecorderEx rex = new RecorderEx();
                rex.Open += new EventHandler(rex_Open);
                rex.Data += new RecorderEx.DataEventHandler(rex_Data);
                rex.Close += new EventHandler(rex_Close);
                rex.Format = AudioCompressionManager.GetPcmFormat(1, 16, 44100);
                rex.StartRecord();
            }
            
            static WaveWriter ww;
            static int i = 0;
            
            static void rex_Close(object sender, EventArgs e)
            {
                ww.Close();
                ww = null;
            }
            
            static void rex_Data(object sender, DataEventArgs e)
            {
                ww.WriteData(e.Data);
                i += 1;
                if (i == 10)
                {
                    ((RecorderEx)sender).StopRecord();
                }
            }
            
            static void rex_Open(object sender, EventArgs e)
            {
                if (ww == null)
                {
                    ww = new WaveWriter(File.Create("rec.wav"), AudioCompressionManager.FormatBytes(((RecorderEx)sender).Format));
                }
            }
             

82. This example shows simple using of GetRecorderName method.


            for (int i = 0; i < RecorderEx.RecorderCount; i++)
            {
                Console.WriteLine(RecorderEx.GetRecorderName(i));
            }
             

83. This example shows simple using of AviReader.


            AviReader ar = new AviReader(File.OpenRead("123.avi"));
            if (ar.HasAudio)
            {
                IntPtr format = ar.ReadFormat();
                byte[] data = ar.ReadData();
            }
            ar.Close();
             

Blog :: Contact Us :: Copyright © 1998-2013 Alvas.Net. All rights reserved