Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

BSEtunes

, 24 Apr 2010
BSEtunes is a MySQL based, full manageable, networkable single or multiuser jukebox application
BSE.Platten.zip
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
Settings.settings
vssver2.scc
Resources
vssver2.scc
BSE.Platten.Admin
BSE.Platten.Admin.csproj.vspscc
mssccprj.scc
vssver2.scc
Properties
Settings.settings
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
Settings.settings
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
Settings.settings
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
Settings.settings
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.Platten_en.zip
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
Settings.settings
vssver2.scc
vssver2.scc
BSE.Platten.Admin.csproj.user
Settings.settings
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
Settings.settings
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
Settings.settings
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
Settings.settings
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.zip
MySqlCreateDataBase5x.sql.zip
using System;
using System.Runtime.InteropServices;
using System.Globalization;
using BSE.Platten.Ripper.Properties;
using System.Security.Permissions;

namespace BSE.Platten.Ripper
{
	public enum VbrMethod : int
	{
		None		= -1,
		Default  	=  0,
		Old			=  1,
		New			=  2,
		Mtrh		=  3,
		Abr			=  4
	}

	/* MPEG modes */
	public enum MpegMode : uint 
	{
		Stereo = 0,
		JointStereo,
		DualChannel,   /* LAME doesn't supports this! */
		Mono,
		NotSet,
		MaxIndicator   /* Don't use this! It's used for sanity checks. */ 
	}

	public enum LameQualityPreset : int
	{
		NoPreset		=-1,
		// QUALITY PRESETS
		NormalQuality	= 0,
		LowQuality		= 1,
		HighQuality		= 2,
		VoiceQuality	= 3,
		R3mix			= 4,
		VeryHighQuality	= 5,
		Standard		= 6,
		FastStandard	= 7,
		Extreme			= 8,
		FastExtreme		= 9,
		Insane			= 10,
		Abr				= 11,
		Cbr				= 12,
		Medium			= 13,
		FastMedium		= 14,
		// NEW PRESET VALUES
		Phone	        =1000,
		SW		        =2000,
		AM		        =3000,
		FM		        =4000,
		Voice	        =5000,
		Radio	        =6000,
		Tape	        =7000,
		Hifi	        =8000,
		CD		        =9000,
		Studio	        =10000
	}

	[StructLayout(LayoutKind.Sequential), Serializable]
	public struct	MP3 //BE_CONFIG_MP3
	{
		public uint   dwSampleRate;		// 48000, 44100 and 32000 allowed
		public byte	  byMode;			// BE_MP3_MODE_STEREO, BE_MP3_MODE_DUALCHANNEL, BE_MP3_MODE_MONO
		public ushort	wBitrate;		// 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320 allowed
		public int	  bPrivate;		
		public int	  bCRC;
		public int	  bCopyright;
		public int	  bOriginal;
	} 

	[StructLayout(LayoutKind.Sequential, Size=327), Serializable]
	public struct LHV1 // BE_CONFIG_LAME LAME header version 1
	{
		public const uint MPEG1	= 1;
		public const uint MPEG2	= 0;

		// STRUCTURE INFORMATION
		public uint				dwStructVersion;	
		public uint				dwStructSize;
		// BASIC ENCODER SETTINGS
		public uint				dwSampleRate;		// SAMPLERATE OF INPUT FILE
		public uint				dwReSampleRate;		// DOWNSAMPLERATE, 0=ENCODER DECIDES  
		public MpegMode			nMode;				// STEREO, MONO
		public uint				dwBitrate;			// CBR bitrate, VBR min bitrate
		public uint				dwMaxBitrate;		// CBR ignored, VBR Max bitrate
		public LameQualityPreset nPreset;			// Quality preset
		public uint				dwMpegVersion;		// MPEG-1 OR MPEG-2
		public uint				dwPsyModel;			// FUTURE USE, SET TO 0
		public uint				dwEmphasis;			// FUTURE USE, SET TO 0
		// BIT STREAM SETTINGS
		public int				bPrivate;			// Set Private Bit (TRUE/FALSE)
		public int				bCRC;				// Insert CRC (TRUE/FALSE)
		public int				bCopyright;			// Set Copyright Bit (TRUE/FALSE)
		public int				bOriginal;			// Set Original Bit (TRUE/FALSE)
		// VBR STUFF
		public int				bWriteVBRHeader;	// WRITE XING VBR HEADER (TRUE/FALSE)
		public int				bEnableVBR;			// USE VBR ENCODING (TRUE/FALSE)
		public int				nVBRQuality;		// VBR QUALITY 0..9
		public uint				dwVbrAbr_bps;		// Use ABR in stead of nVBRQuality
        public VbrMethod        nVbrMethod;
		public int				bNoRes;				// Disable Bit resorvoir (TRUE/FALSE)
		// MISC SETTINGS
		public int				bStrictIso;			// Use strict ISO encoding rules (TRUE/FALSE)
		public ushort			nQuality;			// Quality Setting, HIGH BYTE should be NOT LOW byte, otherwhise quality=5
		// FUTURE USE, SET TO 0, align strucutre to 331 bytes
		//[ MarshalAs( UnmanagedType.ByValArray, SizeConst=255-4*4-2 )]
		//public byte[]   btReserved;//[255-4*sizeof(DWORD) - sizeof( WORD )];
		public LHV1(CWaveFormat format, uint MpeBitRate)
		{
            if (format == null)
            {
                throw new ArgumentNullException(
                    string.Format(CultureInfo.InvariantCulture, Resources.IDS_ArgumentNullException, "format"));
            }
            if ( format.wFormatTag != (short)WaveFormat.Pcm )
			{
				throw new ArgumentOutOfRangeException("format", "Only PCM format supported");
			}
			if ( format.wBitsPerSample != 16)
			{
				throw new ArgumentOutOfRangeException("format", "Only 16 bits samples supported");
			}
			dwStructVersion	= 1;
			dwStructSize		= (uint)Marshal.SizeOf(typeof(BE_CONFIG));
			switch (format.nSamplesPerSec)
			{
				case 16000 :
				case 22050 :
				case 24000 :
					dwMpegVersion		= MPEG2;
					break;
				case 32000 :
				case 44100 :
				case 48000 :
					dwMpegVersion		= MPEG1;
					break;
				default :
					throw new ArgumentOutOfRangeException("format", "Unsupported sample rate");
			}
			dwSampleRate = (uint)format.nSamplesPerSec;				// INPUT FREQUENCY
			dwReSampleRate = 0;					// DON'T RESAMPLE
			switch (format.nChannels)
			{
				case 1 :
					nMode	=	MpegMode.Mono;
					break;
				case 2 :
					nMode = MpegMode.Stereo;
					break;
				default:
					throw new ArgumentOutOfRangeException("format", "Invalid number of channels");
			}
			switch (MpeBitRate)
			{
				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 (dwMpegVersion	!= MPEG1)
					{
						throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
					}
					break;
				case 8 :
				case 16 :
				case 24 :
				case 144 : //Allowed only in MPEG2
					if (dwMpegVersion	!= MPEG2)
					{
						throw new ArgumentOutOfRangeException("MpsBitRate", "Bit rate not compatible with input format");
					}
					break;
				default :
					throw new ArgumentOutOfRangeException("MpsBitRate", "Unsupported bit rate");
			}
			dwBitrate	= MpeBitRate;								// MINIMUM BIT RATE
            nPreset = LameQualityPreset.NormalQuality;      		// QUALITY PRESET SETTING
			dwPsyModel = 0;											// USE DEFAULT PSYCHOACOUSTIC MODEL 
			dwEmphasis = 0;											// NO EMPHASIS TURNED ON
			bOriginal = 1;											// SET ORIGINAL FLAG
			bWriteVBRHeader	= 0;					
			bNoRes = 0;												// No Bit resorvoir
			bCopyright = 0;
			bCRC = 0;
			bEnableVBR = 0;
			bPrivate = 0;
			bStrictIso = 0;
			dwMaxBitrate = 0;
			dwVbrAbr_bps = 0;
			nQuality = 0;
            nVbrMethod = VbrMethod.None;
			nVBRQuality = 0;
		}
	}

	[StructLayout(LayoutKind.Sequential), Serializable]
	public struct Acc
	{
		public uint	dwSampleRate;
		public byte	byMode;
		public ushort wBitrate;
		public byte	byEncodingMethod;
	}

	[StructLayout(LayoutKind.Explicit), Serializable]
	public class Format
	{
		[FieldOffset(0)] 
		public MP3 mp3;
		[FieldOffset(0)]
		public LHV1 lhv1;
		[FieldOffset(0)]
		public Acc acc;

		public Format(CWaveFormat format, uint MpeBitRate)
		{
			lhv1 = new LHV1(format, MpeBitRate);
		}
	}

	[StructLayout(LayoutKind.Sequential), Serializable]
	public class BE_CONFIG
	{
		// encoding formats
		public const uint BE_CONFIG_MP3	 = 0;
		public const uint BE_CONFIG_LAME = 256;

		public uint	dwConfig;	
		public Format format;

		public BE_CONFIG(CWaveFormat format, uint MpeBitRate)
		{
			this.dwConfig = BE_CONFIG_LAME;
			this.format = new Format(format, MpeBitRate);
		}
		public BE_CONFIG(CWaveFormat format) : this(format, 128)
		{
		}
	}

	[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
	public class BE_VERSION
	{ 
		public const uint BE_MAX_HOMEPAGE	= 256;
		public byte	byDLLMajorVersion;
		public byte	byDLLMinorVersion;
		public byte	byMajorVersion;
		public byte	byMinorVersion;
		// DLL Release date
		public byte	byDay;
		public byte	byMonth;
		public ushort	wYear;
		//Homepage URL
		[MarshalAs(UnmanagedType.ByValTStr, SizeConst=257/*BE_MAX_HOMEPAGE+1*/)]
		public string	zHomepage;	
		public byte	byAlphaLevel;
		public byte	byBetaLevel;
		public byte	byMMXEnabled;
		[MarshalAs(UnmanagedType.ByValArray, SizeConst=125)]
		public byte[]	btReserved;
		public BE_VERSION()
		{
			btReserved = new byte[125];
		}
	}
	/// <summary>
	/// Zusammendfassende Beschreibung f�r CLame.
	/// </summary>
	public class LameEncDll
	{
		#region Enumerationen
		
		
		
		#endregion
		
		#region Konstanten
		
		//Error codes
		public const uint BE_ERR_SUCCESSFUL = 0;
		public const uint BE_ERR_INVALID_FORMAT = 1;
		public const uint BE_ERR_INVALID_FORMAT_PARAMETERS = 2;
		public const uint BE_ERR_NO_MORE_HANDLES = 3;
		public const uint BE_ERR_INVALID_HANDLE = 4;
		
		#endregion
		
		#region FieldsProtected
		
		[DllImport("Lame_enc.dll")]
		protected static extern uint beEncodeChunk(uint hbeStream, uint nSamples, IntPtr pSamples, [In, Out] byte[] pOutput, ref uint pdwOutput);
		
		#endregion
		
		#region MethodsPublic

        [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
        public static uint EncodeChunk(uint hbeStream, byte[] buffer, int index, uint nBytes, byte[] pOutput, ref uint pdwOutput)
		{
			uint res;
			GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
			try
			{
				IntPtr ptr = (IntPtr)(handle.AddrOfPinnedObject().ToInt32()+index);
				res = beEncodeChunk(hbeStream, nBytes/2/*Samples*/, ptr, pOutput, ref pdwOutput);
			}
			finally
			{
				handle.Free();
			}
			return res;
		}
        [EnvironmentPermissionAttribute(SecurityAction.LinkDemand, Unrestricted = true)]
		public static uint EncodeChunk(uint hbeStream, byte[] buffer, byte[] pOutput, ref uint pdwOutput)
		{
            if (buffer == null)
            {
                throw new ArgumentNullException(
                    string.Format(
                    CultureInfo.InvariantCulture,
                    Resources.IDS_ArgumentNullException,"buffer"));
            }
            return EncodeChunk(hbeStream, buffer, 0, (uint)buffer.Length, pOutput, ref pdwOutput);
		}

		#endregion

        internal static class NativeMethods
        {
            [DllImport("Lame_enc.dll")]
            public static extern uint beInitStream(BE_CONFIG pbeConfig, ref uint dwSamples, ref uint dwBufferSize, ref uint phbeStream);
            [DllImport("Lame_enc.dll")]
            public static extern uint beEncodeChunk(uint hbeStream, uint nSamples, short[] pInSamples, [In, Out] byte[] pOutput, ref uint pdwOutput);
            [DllImport("Lame_enc.dll")]
            public static extern uint beDeinitStream(uint hbeStream, [In, Out] byte[] pOutput, ref uint pdwOutput);
            [DllImport("Lame_enc.dll")]
            public static extern uint beCloseStream(uint hbeStream);
            [DllImport("Lame_enc.dll")]
            public static extern void beVersion([Out] BE_VERSION pbeVersion);
            [DllImport("Lame_enc.dll", CharSet = CharSet.Ansi)]
            public static extern void beWriteVBRHeader(string pszMP3FileName);
            [DllImport("Lame_enc.dll")]
            public static extern uint beEncodeChunkFloatS16NI(uint hbeStream, uint nSamples, [In]float[] buffer_l, [In]float[] buffer_r, [In, Out]byte[] pOutput, ref uint pdwOutput);
            [DllImport("Lame_enc.dll")]
            public static extern uint beFlushNoGap(uint hbeStream, [In, Out]byte[] pOutput, ref uint pdwOutput);
            [DllImport("Lame_enc.dll", CharSet = CharSet.Ansi)]
            public static extern uint beWriteInfoTag(uint hbeStream, string lpszFileName);
        }
	}
}

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140821.2 | Last Updated 24 Apr 2010
Article Copyright 2009 by Uwe Eichkorn
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid