Beispiel #1
0
        public void Run()
        {
            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);

            string path            = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string luceneIndexPath = ini.IniReadValue("Program", "LuceneIndexPath", Path.Combine(path, @"DB")); // Mag geen Drive letter bevatten!

            if (!luceneIndexPath.Contains(":") || (luceneIndexPath.Length > 0 && luceneIndexPath[0] != '\\'))
            {
                luceneIndexPath = Path.Combine(path, luceneIndexPath);
            }
            string acoustIDFingerMap = ini.IniReadValue("Program", "AcoustIDFingerMap", "AcoustIDFingerMap");
            string subFingerMap      = ini.IniReadValue("Program", "SubFingerMap", "SubFingerLookup");

            AudioFingerprint.Audio.BassLifetimeManager.bass_EMail           = ini.IniReadValue("BASS", "bass_EMail", "");
            AudioFingerprint.Audio.BassLifetimeManager.bass_RegistrationKey = ini.IniReadValue("BASS", "bass_RegistrationKey", "");


            AudioFingerprint.Math.SimilarityUtility.InitSimilarityUtility();

            CreateAcoustIDFingerLookupIndex(Path.Combine(luceneIndexPath, acoustIDFingerMap));
            CreateSubFingerLookupIndex(Path.Combine(luceneIndexPath, subFingerMap));
        }
Beispiel #2
0
        /// <summary>
        /// Setup the class, by intializing path's and the audio engine.
        /// Reads the Fingerprint.ini file for the settings
        /// </summary>
        public Worker()
        {
            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);

            string path            = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string luceneIndexPath = ini.IniReadValue("Program", "LuceneIndexPath", Path.Combine(path, @"DB")); // Mag geen Drive letter bevatten!

            if (!luceneIndexPath.Contains(":") || (luceneIndexPath.Length > 0 && luceneIndexPath[0] != '\\'))
            {
                luceneIndexPath = Path.Combine(path, luceneIndexPath);
            }
            string acoustIDFingerMap = ini.IniReadValue("Program", "AcoustIDFingerMap", "AcoustIDFingerMap");
            string subFingerMap      = ini.IniReadValue("Program", "SubFingerMap", "SubFingerLookup");

            wsAPICDRNL_User = ini.IniReadValue("Muziekweb", "wsAPICDRNL_User", wsAPICDRNL_User);

            // Are we using the muziekweb dataset, Yes than metadata can be requested
            // other datasets can not be used, because ID's do not match
            retrieveMetadataFromMuziekweb = (Exec_MySQL_TITELNUMMERTRACK_ID_COUNT() > 1000000); // this is probally the muziekweb dataset

            AudioFingerprint.Audio.BassLifetimeManager.bass_EMail           = ini.IniReadValue("BASS", "bass_EMail", "");
            AudioFingerprint.Audio.BassLifetimeManager.bass_RegistrationKey = ini.IniReadValue("BASS", "bass_RegistrationKey", "");


            acoustIDfingerLookupPath = Path.Combine(luceneIndexPath, acoustIDFingerMap);
            subFingerLookupPath      = Path.Combine(luceneIndexPath, subFingerMap);

            AudioFingerprint.Math.SimilarityUtility.InitSimilarityUtility();
            audioEngine = new AudioEngine();
        }
Beispiel #3
0
        public WSRecognize()
        {
            this.synchronizationContext = SynchronizationContext.Current;

            int newValue = Interlocked.Increment(ref ignoreSSLCertifivcateCount);

            // eerste keer?
            if (newValue == 1)
            {
                ServicePointManager.ServerCertificateValidationCallback += ValidateServerCertificate;
            }
            ServicePointManager.DefaultConnectionLimit = 4; // default is 4
            ServicePointManager.Expect100Continue      = false;
            ServicePointManager.UseNagleAlgorithm      = false;


            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            if (System.IO.File.Exists(IniPath))
            {
                CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                wsProtocol  = ini.IniReadValue("WSRecognize", "wsProtocol", wsProtocol);
                wsDNSFinger = ini.IniReadValue("WSRecognize", "wsDNSFinger", wsDNSFinger);
                wsPort      = ini.IniReadValue("WSRecognize", "wsPort", wsPort);
                wsUser      = ini.IniReadValue("WSRecognize", "wsUser", wsUser);
                wsPassword  = ini.IniReadValue("WSRecognize", "wsPassword", wsPassword);

                wsAPICDRNL_Protocol = ini.IniReadValue("Muziekweb", "wsAPICDRNL_Protocol", wsAPICDRNL_Protocol);
                wsAPICDRNL_DNS      = ini.IniReadValue("Muziekweb", "wsAPICDRNL_DNS", wsAPICDRNL_DNS);
                wsAPICDRNL_Port     = ini.IniReadValue("Muziekweb", "wsAPICDRNL_Port", wsAPICDRNL_Port);
                wsAPICDRNL_User     = ini.IniReadValue("Muziekweb", "wsAPICDRNL_User", wsAPICDRNL_User);
                wsAPICDRNL_Password = ini.IniReadValue("Muziekweb", "wsAPICDRNL_Password", wsAPICDRNL_Password);
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Version version     = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
            string  versionType = "";

#if DEBUG
            versionType = " [DEBUG]";
#endif
            string title = String.Format("RadioChannel v{0:0}.{1:00}{2}", version.Major, version.Minor, versionType);
            Console.Title = title;
            Console.WriteLine(title);
            Console.WriteLine();

            if (IntPtr.Size == 4)
            {
                Console.WriteLine("This application must run in 64bits mode.");
                Environment.Exit(1);
            }

            string iniFilename = Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, ".ini");

            string radioCode = string.Empty;
            if (File.Exists(iniFilename))
            {
                CDR.Ini.IniFile ini = new CDR.Ini.IniFile(iniFilename);
                radioCode = ini.IniReadValue("Settings", "RadioCode", "");
            }
            if (args.Length > 0)
            {
                foreach (string arg in args)
                {
                    if (arg.Length > 7 && arg.ToUpper().Substring(0, 7) == "/RADIO:")
                    {
                        radioCode = arg.ToUpper().Substring(7);
                    }
                }
            }

            if (File.Exists(iniFilename))
            {
                CDR.Ini.IniFile ini  = new CDR.Ini.IniFile(iniFilename);
                int             xPos = Convert.ToInt32(ini.IniReadValue(radioCode, "WindowXPos", "0"));
                int             yPos = Convert.ToInt32(ini.IniReadValue(radioCode, "WindowYPos", "0"));
                if (xPos != 0 && yPos != 0)
                {
                    SetWindowPos(myConsole, 0, xPos, yPos, 0, 0, SWP_NOSIZE);
                }
            }
            Program.StoreConsoleWindowPosition(radioCode);

            Channel channel = new Channel();
            channel.RunChannel(radioCode);

            Program.StoreConsoleWindowPosition(radioCode);
        }
Beispiel #5
0
        public static void StoreConsoleWindowPosition(string radioCode)
        {
            string iniFilename = Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, ".ini");

            RECT rect;

            if (GetWindowRect(myConsole, out rect))
            {
                CDR.Ini.IniFile ini = new CDR.Ini.IniFile(iniFilename);
                ini.IniWriteValue(radioCode, "WindowXPos", rect.Left.ToString());
                ini.IniWriteValue(radioCode, "WindowYPos", rect.Top.ToString());
            }
        }
Beispiel #6
0
        static LuceneIndexes()
        {
            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            if (System.IO.File.Exists(IniPath))
            {
                try
                {
                    CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                    luceneIndexPath = ini.IniReadValue("Program", "LuceneIndexPath", luceneIndexPath);
                    dbSubFingerMap  = ini.IniReadValue("Program", "SubFingerMap", dbSubFingerMap);
                }
                catch { }
            }
            dbSubFingerMap = Path.GetFullPath(Path.Combine(luceneIndexPath, dbSubFingerMap));
        }
Beispiel #7
0
 private static void Initialize()
 {
     if (!Initialized)
     {
         string IniPath = CDR.DB_Helper.FingerprintIniFile;
         if (System.IO.File.Exists(IniPath))
         {
             try
             {
                 CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                 EMail_Automatisering = ini.IniReadValue("Mail", "EMail", EMail_Automatisering);
                 SMTPServer           = ini.IniReadValue("Mail", "SMTPServer", SMTPServer);
             }
             catch { }
         }
         Initialized = true;
     }
 }
        /// <summary>
        /// static constructor die private class initieert zodat destructor werkt (static destructor werkt blijkbaar niet)
        /// </summary>
        static SMTPLogging()
        {
            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            if (System.IO.File.Exists(IniPath))
            {
                try
                {
                    CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                    EMail_Automatisering = ini.IniReadValue("Mail", "EMail", EMail_Automatisering);
                    SMTPServer           = ini.IniReadValue("Mail", "SMTPServer", SMTPServer);
                }
                catch { }
            }

            logRows    = new Queue <LogSMTPMessage>();
            _singleton = new SMTPLogging();
        }
Beispiel #9
0
        /// <summary>
        /// Retrieve special settinggs for radiochannel
        /// </summary>
        private void GetSettings()
        {
            string iniFilename = Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, ".ini");

            if (File.Exists(iniFilename))
            {
                System.Globalization.NumberFormatInfo nfi = new System.Globalization.CultureInfo("en-US", false).NumberFormat;
                nfi.CurrencySymbol           = "€";
                nfi.CurrencyDecimalDigits    = 2;
                nfi.CurrencyDecimalSeparator = ".";
                nfi.NumberGroupSeparator     = "";
                nfi.NumberDecimalSeparator   = ".";

                CDR.Ini.IniFile ini = new CDR.Ini.IniFile(iniFilename);
                doTimeStretching      = (ini.IniReadValue(radioCode, "Preprocessor1", "").ToUpper() == "TIMESTRETCH");
                timeStretchRateFactor = Convert.ToSingle(ini.IniReadValue(radioCode, "Preprocessor1Parameter1", "0.0"), nfi);
                webServiceCall        = ini.IniReadValue(radioCode, "WebServiceCall", "DEFAULT");
            }
        }
        public BassLifetimeManager(bool initializeRecordDevice = false)
        {
            lock (lockObject)
            {
                if (IsBassLibraryHasToBeInitialized(Interlocked.Increment(ref initializedInstances)))
                {
                    string IniPath = CDR.DB_Helper.FingerprintIniFile;
                    if (System.IO.File.Exists(IniPath))
                    {
                        try
                        {
                            CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                            bass_EMail           = ini.IniReadValue("BASS", "bass_EMail", bass_EMail);
                            bass_RegistrationKey = ini.IniReadValue("BASS", "bass_RegistrationKey", bass_RegistrationKey);
                        }
                        catch { }
                    }

                    RegisterBassKey();
                    string targetPath = GetTargetPathToLoadLibrariesFrom();
                    LoadBassLibraries(targetPath);
                    CheckIfFlacPluginIsLoaded(targetPath);
                    //CheckIfAacPluginIsLoaded(targetPath);

                    InitializeBassLibraryWithAudioDevices();
                    SetDefaultConfigs();
                    if (initializeRecordDevice)
                    {
                        InitializeRecordingDevice();
                    }
                    bassInitialized = true;
                }
                else
                {
                    // wait till bass lib is intialized
                    while (!bassInitialized)
                    {
                        Thread.Sleep(10);
                    }
                }
            }
        }
Beispiel #11
0
        public static void RestoreConsoleWindowPosition(string section)
        {
            try
            {
                string iniFilename = Path.ChangeExtension(System.Reflection.Assembly.GetExecutingAssembly().Location, ".ini");

                if (File.Exists(iniFilename))
                {
                    CDR.Ini.IniFile ini  = new CDR.Ini.IniFile(iniFilename);
                    int             xPos = Convert.ToInt32(ini.IniReadValue(section, "WindowXPos", "0"));
                    int             yPos = Convert.ToInt32(ini.IniReadValue(section, "WindowYPos", "0"));
                    if (xPos != 0 && yPos != 0)
                    {
                        SetWindowPos(myConsole, 0, xPos, yPos, 0, 0, SWP_NOSIZE);
                    }
                }
            }
            catch
            {
            }
        }
 public static void Initialize()
 {
     if (!initialized)
     {
         string IniPath = CDR.DB_Helper.FingerprintIniFile;
         if (System.IO.File.Exists(IniPath))
         {
             try
             {
                 CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                 mysqlServer   = ini.IniReadValue("MySQL", "mysqlServer", mysqlServer);
                 mysqlPort     = ini.IniReadValue("MySQL", "mysqlPort", mysqlPort);
                 mysqlDB       = ini.IniReadValue("MySQL", "mysqlDB", mysqlDB);
                 mysqlUser     = ini.IniReadValue("MySQL", "mysqlUser", mysqlUser);
                 mysqlPassword = ini.IniReadValue("MySQL", "mysqlPassword", mysqlPassword);
             }
             catch { }
         }
         initialized = true;
     }
 }
Beispiel #13
0
        static CDRLogger()
        {
            string IniPath = CDR.DB_Helper.FingerprintIniFile;

            if (System.IO.File.Exists(IniPath))
            {
                try
                {
                    CDR.Ini.IniFile ini = new CDR.Ini.IniFile(IniPath);
                    EMail_Automatisering = ini.IniReadValue("Mail", "EMail", EMail_Automatisering);
                    SMTPServer           = ini.IniReadValue("Mail", "SMTPServer", SMTPServer);
                }
                catch { }
            }

            // Gebruik eigen formatter
            BitFactory.Logging.Logger.DefaultFormatterClass = typeof(LogEntryCDRFormatter);

            // We gebruiken de application naam als filename voor het log bestand.
            filename = String.Format(".\\{0}.log", System.Reflection.Assembly.GetExecutingAssembly().GetName().Name);
            if (File.Exists(filename))
            {
                // We voegen info toe om te vertellen dat dit een nieuwe restart is van de applicatie
                using (StreamWriter w = File.AppendText(filename))
                {
                    w.WriteLine();
                    w.WriteLine(String.Format("Application started at {0:yyyy-MM-dd HH:mm:ss.fff}", DateTime.Now));
                    w.WriteLine();
                } //using
            }     //if file exists

            Logger = new CompositeLogger();
            // voeg altijd memory logger toe
            memoryLogger = new MemoryLogger(1000); // capacity van 1000 regels maximaal daarna worden de oude overschreven
            Logger.AddLogger("MemoryLogger", memoryLogger);

            fileLogger = new FileLogger(filename);
            Logger.AddLogger("FileLogger", fileLogger);
        }
Beispiel #14
0
        public void RunChannel(string radioChannelCode)
        {
            DataRow row;

            if (!Exec_MySQL_RADIOCHANNEL_S(radioChannelCode, out row))
            {
                Console.WriteLine("No radiochannel available. Please set correct 'RadioCode' in ini file");
                return;
            }

            dict = new ConcurrentDictionary <string, DetectSong>();

            radioName    = row["RADIONAME"].ToString();
            radioCode    = row["NAMECODE"].ToString();
            radioChannel = Convert.ToInt32(row["RADIOCHANNEL_ID"]);
            GetSettings();
            SetWindowTitle();

            try
            {
                CDR.Ini.IniFile ini = new CDR.Ini.IniFile(CDR.DB_Helper.FingerprintIniFile);
                wsAPICDRNL_User = ini.IniReadValue("Muziekweb", "wsAPICDRNL_User", wsAPICDRNL_User);
            }
            catch { }

            // Are we using the muziekweb dataset, Yes than metadata can be requested
            // other datasets can not be used, because ID's do not match
            retrieveMetadataFromMuziekweb = (Exec_MySQL_TITELNUMMERTRACK_ID_COUNT() > 1000000); // this is probally the muziekweb dataset


            Console.WriteLine(string.Format("Listing to '{0}'.", radioName));

            // Kies een tijd uit waarbij de minuut in het uur ('s nachts 2 uur) random is gekozen
            // (zodat ze niet allemaal tegelijktijd stoppen met werken)
            Random   random          = new Random();
            DateTime dtStopListening = DateTime.Now.Date.Add(new TimeSpan(1, 2, random.Next(0, 59), 0, 0));

            SetupStream(out radioStream, row["URL"].ToString());
            try
            {
                bool stop = false;
                do
                {
                    if (Console.KeyAvailable)
                    {
                        ConsoleKeyInfo key = Console.ReadKey(true);
                        if (key.KeyChar == '\r')
                        {
                            stop = true;
                            break;
                        }
                        else if (char.ToUpper(key.KeyChar) == 'W')
                        {
                            doWriteChunksToWAVFile = !doWriteChunksToWAVFile;
                            SetWindowTitle();
                        }
                        else if (char.ToUpper(key.KeyChar) == 'A')
                        {
                            doAudioOn = !doAudioOn;
                            SetWindowTitle();
                            radioStream.Listen = doAudioOn;
                        }
                    }

                    Thread.Sleep(100);
                    if ((DateTime.Now - dtLastEvent).TotalSeconds > 30)
                    {
                        // Het is telang geleden dat we enig leven van de icestream class hebben gekregen
                        // Kill het en maak een nieuwe aan.
                        dtLastEvent = DateTime.MaxValue;
                        Console.WriteLine();
                        Console.WriteLine(radioName + ": Killing app and restarting it");

                        Program.StoreConsoleWindowPosition(radioChannelCode);

                        // terminate this process and restart it (to avoid block/lock problems)
                        System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, GetCommandParameters());
                        stop = true;
                        break;
                    }

                    if ((DateTime.Now - dtStopListening).TotalSeconds > 0)
                    {
                        // we stoppen zonder stop te zetten!
                        System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location, GetCommandParameters());
                        break;
                    }
                } while (!stop);

                CleanUpDict(true);
            }
            finally
            {
                if (radioStream != null)
                {
                    radioStream.Stop(); // close is the same
                    radioStream = null;
                }
            }
        }