Click here to Skip to main content
12,358,497 members (61,496 online)
Click here to Skip to main content

Stats

38.8K views
3.9K downloads
57 bookmarked
Posted

BSEtunes

, 24 Apr 2010 CPOL
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
BSE.Platten
BSE.Platten.vssscc
mssccprj.scc
vssver2.scc
BSE.CoverFlow.WPFLib
BSE.CoverFlow.WPFLib.csproj.user
BSE.CoverFlow.WPFLib.csproj.vspscc
mssccprj.scc
vssver2.scc
Images
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
Properties
vssver2.scc
Resources
vssver2.scc
BSE.Platten.Admin
BSE.Platten.Admin.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp
BSE.Platten.Admin.WinApp.csproj.user
BSE.Platten.Admin.WinApp.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEadmin.ico
vssver2.scc
BSE.Platten.Audio
bse.ico
BSE.Platten.Audio.csproj.vspscc
mssccprj.scc
vssver2.scc
Options
vssver2.scc
Player
vssver2.scc
Properties
vssver2.scc
Resources
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
WinControls
vssver2.scc
WMFSDK
vssver2.scc
BSE.Platten.BO
BSE.Platten.BO.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Common
BSE.Platten.Common.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers
BSE.Platten.Covers.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.FreeDb
BSE.Platten.FreeDb.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
vssver2.scc
BSE.Platten.Ripper
BSE.Platten.Ripper.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
Resources
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik
BSE.Platten.Statistik.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
vssver2.scc
BSE.Platten.Tunes
BSE.Platten.Tunes.csproj.user
BSE.Platten.Tunes.csproj.vspscc
mssccprj.scc
vssver2.scc
Filters
vssver2.scc
Properties
vssver2.scc
Resources
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup
BSEadminSetup.vdproj
BSEadminSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
BSEtunesSetup
BSEtunesSetup.vdproj
BSEtunesSetup.vdproj.vspscc
mssccprj.scc
vssver2.scc
Debug
Release
dll
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.Windows.Forms.DLL
Lame
lame_enc.dll
vssver2.scc
lame-3.97
BSE.CoverFlow.WPFLib.csproj.user
close.png
exit.png
next.png
next_disabled.png
Note.jpg
pause.png
PlayButton.png
previous.png
previous_disabled.png
stop.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.Admin.csproj.user
vssver2.scc
Album16.gif
BSEadmin.ico
cdimport.png
cdrip.png
cd_hoeren.png
clearsearch.png
DataContainer_MoveFirsHS.png
DataContainer_MoveLastHS.png
DataContainer_MoveNextHS.png
DataContainer_MovePreviousHS.png
DataContainer_NewRecordHS.png
diskinfo.png
DRIVEDSC.png
DRIVENET.png
Edit_UndoHS.png
exportimage.png
findfile.png
FindHS.png
freedb.png
Genre16.png
Image.png
InsertPictureHS.png
Interpret16.png
OptionsHS.png
PieChart3DHS.png
PieChartHS.png
ProtectFormHS.png
RefreshDocViewHS.png
saveHS.png
search.png
song.png
system.png
tagger.png
tools_16.png
vssver2.scc
BSE.Platten.Admin.WinApp.csproj.user
vssver2.scc
BSEadmin.ico
vssver2.scc
bse.ico
BSE.Platten.Audio.csproj.user
vssver2.scc
vssver2.scc
vssver2.scc
FillDownHS.png
FillLeftHS.png
Folder256.png
FolderFind.png
FolderOpen256.png
GoLtrHS.png
MoveNext.png
MovePrevious.png
OptionsHS.png
PauseHS.png
PlayHS.png
Slider.gif
Start.png
StopHS.png
vssver2.scc
vssver2.scc
vssver2.scc
BSE.Platten.BO.csproj.user
vssver2.scc
BSE.Platten.Common.csproj.user
vssver2.scc
BSEsplash.png
DRIVEDSC.png
DRIVENET.png
Network.png
splash.png
vssver2.scc
BSE.Platten.Covers.csproj.user
vssver2.scc
BSE.Platten.FreeDb.csproj.user
vssver2.scc
OpenCD.png
vssver2.scc
AudioWriter
vssver2.scc
BSE.Platten.Ripper.csproj.user
Lame
vssver2.scc
vssver2.scc
OpenCD.png
OptionsHS.png
vssver2.scc
BSE.Platten.Statistik.csproj.user
vssver2.scc
BSE.Platten.Tunes.csproj.user
vssver2.scc
vssver2.scc
About.png
Album16.gif
AudioCD.png
AudioFile.png
AutoList.png
broadcast.png
BSE.png
BSEAbout.png
BSEsplash.png
BSEtunes.ico
BSE_16.png
cd_hoeren.png
coverflow.png
DataContainer_MoveNextHS.png
delete.gif
diskinfo.png
Filter2HS.png
FindHS.png
Folder256.png
FolderOpen256.png
Genre16.gif
Interpret16.gif
keinBild.gif
NewPlaylist16.gif
OptionsHS.png
PauseHS.png
RefreshDocViewHS.png
Removabledrive.png
saveHS.png
search.png
shuffle.png
Shuffle_icon.png
song.png
splash1.png
StopHS.png
TaskHS.png
TrackInfo.gif
vssver2.scc
wiedergabe16.gif
BSEadminSetup.vdproj
BSEtunesSetup.vdproj
BSE.CDDrives.DLL
BSE.Charts.DLL
BSE.Configuration.DLL
BSE.RemovableDrives.DLL
BSE.Shell.DLL
BSE.ThreadedShell.DLL
BSE.Windows.Forms.DLL
lame_enc.dll
MySQL.chm
//
//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
//  PURPOSE. IT CAN BE DISTRIBUTED FREE OF CHARGE AS LONG AS THIS HEADER 
//  REMAINS UNCHANGED.
//
//  Email:  yetiicb@hotmail.com
//
//  Copyright (C) 2002-2003 Idael Cardoso. 
//  
//  LAME ( LAME Ain't an Mp3 Encoder ) 
//  You must call the fucntion "beVersion" to obtain information  like version 
//  numbers (both of the DLL and encoding engine), release date and URL for 
//  lame_enc's homepage. All this information should be made available to the 
//  user of your product through a dialog box or something similar.
//  You must see all information about LAME project and legal license infos at 
//  http://www.mp3dev.org/  The official LAME site
//
//
//  About Thomson and/or Fraunhofer patents:
//  Any use of this product does not convey a license under the relevant 
//  intellectual property of Thomson and/or Fraunhofer Gesellschaft nor imply 
//  any right to use this product in any finished end user or ready-to-use final 
//  product. An independent license for such use is required. 
//  For details, please visit http://www.mp3licensing.com.
//
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Globalization;
using BSE.Platten.Ripper.Properties;
using System.Security.Permissions;
using BSE.Platten.Ripper.AudioWriters;
using System.Diagnostics.CodeAnalysis;

namespace BSE.Platten.Ripper.Lame
{
    [StructLayout(LayoutKind.Sequential, Size = 327), Serializable]
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
    public struct LHV1 // BE_CONFIG_LAME LAME header version 1
    {
        #region Events
        #endregion

        #region Constants
        public const uint Mpeg1 = 1;
        public const uint Mpeg2 = 0;
        #endregion

        #region FieldsPrivate
        #endregion

        #region Properties
        
        #region STRUCTURE INFORMATION
        /// <summary>
        /// Gets or sets the StructVersion.
        /// </summary>
        public uint StructVersion
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the StructSize.
        /// </summary>
        public uint StructSize
        {
            get;
            set;
        }
        #endregion
        
        #region BASIC ENCODER SETTINGS
        /// <summary>
        /// Gets or sets the SampleRate of the input file
        /// </summary>
        public uint SampleRate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the downsamplerate. 0=ENCODER DECIDES
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public uint ReSamplerate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the <see cref="MpegMode"/> mode
        /// </summary>
        public MpegMode Mode
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the VBR min bitrate.
        /// </summary>
        public uint Bitrate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the VBR max bitrate.
        /// </summary>
        public uint MaxBitrate
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the <see cref="LameQualityPreset"/> preset.
        /// </summary>
        public LameQualityPreset Preset
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the MpegVersion.
        /// </summary>
        /// <remarks>MPEG-1 OR MPEG-2</remarks>
        public uint MpegVersion
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the PsyModel.
        /// </summary>
        /// <remarks>The is for future use. Set the value to 0.</remarks>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public uint PsyModel
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the Emphasis.
        /// </summary>
        /// <remarks>The is for future use. Set the value to 0.</remarks>
        public uint Emphasis
        {
            get;
            set;
        }
        #endregion

        #region BIT STREAM SETTINGS
        /// <summary>
        /// Gets or sets the private bit.
        /// </summary>
        public int Private
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the CRC.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public int CRC
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the copyright bit.
        /// </summary>
        public int Copyright
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the original bit.
        /// </summary>
        public int Original
        {
            get;
            set;
        }
        #endregion
        
        #region VBR STUFF
        /// <summary>
        /// Gets or sets an information whether the XING VBR HEADER should be written.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public int WriteVBRHeader
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets an information whether the VBR ENCODING should be used.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public int EnableVBR
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets VBR quality.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public int VBRQuality
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets an information whether ABR should be used in stead VBRQuality.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public uint VBRAbrBps
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the <see cref="VBRMethod"/> enumeration value.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly")]
        public VBRMethod VBRMethod
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets an information whether the Bit resorvoir should be disabled.
        /// </summary>
        public int NoRes
        {
            get;
            set;
        }
        #endregion

        #region MISC SETTINGS
        /// <summary>
        /// Gets or sets an information whether the strict ISO encoding rules should be used.
        /// </summary>
        public int UseStrictIso
        {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the quality settings.
        /// </summary>
        /// <remarks>HIGH BYTE should be NOT LOW byte, otherwhise quality=5</remarks>
        public ushort Quality
        {
            get;
            set;
        }
        #endregion

        #endregion

        #region MethodsPublic
        /// <summary>
        /// Initializes a new instance of the <see cref="LHV1"/> class.
        /// </summary>
        /// <param name="format">The <see cref="WaveFormat"/> object.</param>
        /// <param name="mpegBitrate">The mpegBitrate value.</param>
        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
        public LHV1(WaveFormat format, uint mpegBitrate) : this()
        {
            if (format == null)
            {
                throw new ArgumentNullException(
                    string.Format(CultureInfo.InvariantCulture, Resources.IDS_ArgumentNullException, "format"));
            }
            if (format.FormatTag != (short)WaveFormats.Pcm)
            {
                throw new ArgumentOutOfRangeException("format", "Only PCM format supported");
            }
            if (format.BitsPerSample != 16)
            {
                throw new ArgumentOutOfRangeException("format", "Only 16 bits samples supported");
            }
            this.StructVersion = 1;
            StructSize = (uint)Marshal.SizeOf(typeof(BeConfiguration));
            SetMpegVersion(format);
            this.SampleRate = (uint)format.SamplesPerSec;				// INPUT FREQUENCY
            this.ReSamplerate = 0;					// DON'T RESAMPLE
            SetMpegMode(format);
            CheckMpegVersion(mpegBitrate, this.MpegVersion);
            this.Bitrate = mpegBitrate;								// MINIMUM BIT RATE
            this.Preset = LameQualityPreset.NormalQuality;      	// QUALITY PRESET SETTING
            this.PsyModel = 0;										// USE DEFAULT PSYCHOACOUSTIC MODEL 
            this.Emphasis = 0;										// NO EMPHASIS TURNED ON
            this.Original = 1;										// SET ORIGINAL FLAG
            this.WriteVBRHeader = 0;
            this.NoRes = 0;											// No Bit resorvoir
            this.Copyright = 0;
            this.CRC = 0;
            this.EnableVBR = 0;
            this.Private = 0;
            this.UseStrictIso = 0;
            this.MaxBitrate = 0;
            this.VBRAbrBps = 0;
            this.Quality = 0;
            this.VBRMethod = VBRMethod.None;
            this.VBRQuality = 0;
        }
        /// <summary>
        /// Specifies whether this <see cref="LHV1"/> contains the same properties as the specified Object.
        /// </summary>
        /// <param name="obj">The Object to test.</param>
        /// <returns><b>true</b> if obj is a <see cref="LHV1"/> and has the same properties as this <see cref="LHV1"/>.</returns>
        public override bool Equals(object obj)
        {
            if ((obj is LHV1) == false)
            {
                return false;
            }
            return Equals((LHV1)obj);
        }
        /// <summary>
        /// Specifies whether this <see cref="LHV1"/> contains the same properties as the specified Object.
        /// </summary>
        /// <param name="lhv">The <see cref="LHV1"/> struct to test.</param>
        /// <returns><b>true</b> if obj is a <see cref="LHV1"/> and has the same properties as this <see cref="LHV1"/>.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public bool Equals(LHV1 lhv)
        {
            if (this.StructVersion.Equals(lhv.StructVersion) == false)
            {
                return false;
            }
            if (this.StructSize.Equals(lhv.StructSize) == false)
            {
                return false;
            }
            if (this.SampleRate.Equals(lhv.SampleRate) == false)
            {
                return false;
            }
            if (this.ReSamplerate.Equals(lhv.ReSamplerate) == false)
            {
                return false;
            }
            if (this.Mode.Equals(lhv.Mode) == false)
            {
                return false;
            }
            if (this.Bitrate.Equals(lhv.Bitrate) == false)
            {
                return false;
            }
            if (this.MaxBitrate.Equals(lhv.MaxBitrate) == false)
            {
                return false;
            }
            if (this.Preset.Equals(lhv.Preset) == false)
            {
                return false;
            }
            if (this.MpegVersion.Equals(lhv.MpegVersion) == false)
            {
                return false;
            }
            if (this.PsyModel.Equals(lhv.PsyModel) == false)
            {
                return false;
            }
            if (this.Emphasis.Equals(lhv.Emphasis) == false)
            {
                return false;
            }
            if (this.Private.Equals(lhv.Private) == false)
            {
                return false;
            }
            if (this.CRC.Equals(lhv.CRC) == false)
            {
                return false;
            }
            if (this.Copyright.Equals(lhv.Copyright) == false)
            {
                return false;
            }
            if (this.Original.Equals(lhv.Original) == false)
            {
                return false;
            }
            if (this.WriteVBRHeader.Equals(lhv.WriteVBRHeader) == false)
            {
                return false;
            }
            if (this.EnableVBR.Equals(lhv.EnableVBR) == false)
            {
                return false;
            }
            if (this.VBRQuality.Equals(lhv.VBRQuality) == false)
            {
                return false;
            }
            if (this.VBRAbrBps.Equals(lhv.VBRAbrBps) == false)
            {
                return false;
            }
            if (this.VBRMethod.Equals(lhv.VBRMethod) == false)
            {
                return false;
            }
            if (this.NoRes.Equals(lhv.NoRes) == false)
            {
                return false;
            }
            if (this.UseStrictIso.Equals(lhv.UseStrictIso) == false)
            {
                return false;
            }
            if (this.Quality.Equals(lhv.Quality) == false)
            {
                return false;
            }
            return true;
        }
        /// <summary>
        /// Checks for equality between two <see cref="LHV1"/> structs.
        /// </summary>
        /// <param name="mp31">The first <see cref="LHV1"/> struct to test.</param>
        /// <param name="mp32">The second <see cref="LHV1"/> struct to test.</param>
        /// <returns><b>true</b> if the <see cref="LHV1"/>s are equal; <b>false</b> if <see cref="LHV1"/>s are not equal.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public static bool operator ==(LHV1 lhv1, LHV1 lhv2)
        {
            return lhv1.Equals(lhv2);
        }
        /// <summary>
        /// Checks for inequality between two <see cref="LHV1"/> structs.
        /// </summary>
        /// <param name="lhv1">The first <see cref="LHV1"/> struct to test.</param>
        /// <param name="lhv2">The second <see cref="LHV1"/> struct to test.</param>
        /// <returns><b>true</b> if the <see cref="LHV1"/>s are not equal; <b>false</b> if <see cref="LHV1"/>s are equal.</returns>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")]
        public static bool operator !=(LHV1 lhv1, LHV1 lhv2)
        {
            return !lhv1.Equals(lhv2);
        }
        /// <summary>
        /// Returns a hash code for this <see cref="LHV1"/>.
        /// </summary>
        /// <returns>An integer value that specifies a hash value for this <see cref="LHV1"/>.</returns>
        public override int GetHashCode()
        {
            return this.Private ^ this.CRC ^ this.Copyright ^ this.Original ^ this.WriteVBRHeader ^ this.EnableVBR ^ this.VBRQuality ^ this.NoRes ^ this.UseStrictIso;
        }  
        #endregion

        #region MethodsPrivate
        private void SetMpegVersion(WaveFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(
                    string.Format(CultureInfo.InvariantCulture, Resources.IDS_ArgumentNullException, "format"));
            }
            switch (format.SamplesPerSec)
            {
                case 16000:
                case 22050:
                case 24000:
                    this.MpegVersion = Mpeg2;
                    break;
                case 32000:
                case 44100:
                case 48000:
                    this.MpegVersion = Mpeg1;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("format", "Unsupported sample rate");
            }
        }
        private void SetMpegMode(WaveFormat format)
        {
            if (format == null)
            {
                throw new ArgumentNullException(
                    string.Format(CultureInfo.InvariantCulture, Resources.IDS_ArgumentNullException, "format"));
            }
            switch (format.Channels)
            {
                case 1:
                    this.Mode = MpegMode.Mono;
                    break;
                case 2:
                    this.Mode = MpegMode.Stereo;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("format", "Invalid number of channels");
            }
        }
        [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
        private static void CheckMpegVersion(uint mpegBitrate, uint mpegversion)
        {
            switch (mpegBitrate)
            {
                case 32:
                case 40:
                case 48:
                case 56:
                case 64:
                case 80:
                case 96:
                case 112:
                case 128:
                case 160: //Allowed bit rates in MPEG1 and MPEG2
                    break;
                case 192:
                case 224:
                case 256:
                case 320: //Allowed only in MPEG1
                    if (mpegversion != Mpeg1)
                    {
                        throw new ArgumentOutOfRangeException("mpegversion", "Bit rate not compatible with input format");
                    }
                    break;
                case 8:
                case 16:
                case 24:
                case 144: //Allowed only in MPEG2
                    if (mpegversion != Mpeg2)
                    {
                        throw new ArgumentOutOfRangeException("mpegversion", "Bit rate not compatible with input format");
                    }
                    break;
                default:
                    throw new ArgumentOutOfRangeException("mpegBitrate", "Unsupported bit rate");
            }
        }
        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Uwe Eichkorn
Switzerland Switzerland
No Biography provided

You may also be interested in...