Example #1
0
        public static List <List <bool> > GetSignature(string musicPath, float beat, float globalThreshold)
        {
            // Extract data and sample rate from audio file
            float sampleRate = SoundSignatureGenerator2.GetMp3SampleRate(musicPath);

            float[] music = SoundSignatureGenerator2.GetRawMp3Frames(musicPath);

            // Generate signature

            return(CreateSignature(music, beat, sampleRate, globalThreshold));
        }
Example #2
0
        static void Main()
        {
            BPMTFF          bpmtff          = new BPMTFF();
            SoundSignature  soundSignature  = new SoundSignature();
            DWTBeatDetector dwtBeatDetector = new DWTBeatDetector();

            string path   = "music/unity.mp3";
            string output = "music/unity.txt";

            float sampleRate = GetMp3SampleRate(path);

            float[] music = GetRawMp3Frames(path);

            /* sound signature */
            //List<bool> signature = SoundSignatureGenerator2.GetSignature(path, 175, 0.5f);


            int a = 1;
            List <List <bool> > signature = SoundSignatureGenerator2.GetSignature(path, 105, 0);

            SoundSignatureFileManager.SaveSoundSignature(output, signature);
            //SoundSignatureFileManager.SaveSoundSignature("music/text.txt", signature);
            //List<List<bool>> signature2 = SoundSignatureFileManager.LoadSoundSignature("music/text.txt");
            //Console.WriteLine(signature2 == signature);

            /* Beat detector
             * int windowTime = 4;
             * int nbFrames = (int)(music.Length / windowTime / sampleRate)
             * float[] beat = new float[nbFrames];
             * for (int i = 0; i < nbFrames-1; i++)
             * {
             *  float[] music2 = new float[(int)(windowTime * sampleRate)];
             *  for (int j = 0; j < music2.Length; j++)
             *  {
             *      music2[j] = music[(int) (j + i * windowTime * sampleRate)];
             *  }
             *  beat[i] = dwtBeatDetector.Beat(music2);
             *  Console.WriteLine(beat[i]);
             * }
             */


            /* BPMTFF
             * float[] music = GetRawMp3Frames(path);
             * float[] sample = bpmtff.CreateS[iampling(music);
             *
             *
             * float[][] fftsignal = bpmtff.FilterBank(sample);
             * float[][] fftsignal2 = bpmtff.Hwindow(fftsignal);
             * float[][] fftsignal3 = bpmtff.DiffRect(fftsignal2);
             * //float[] bpms = bpmtff.TimeComb(fftsignal3);
             *
             *
             */


            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form1 form = new Form1();

            //form.plotGraph(signature);
            Application.Run(form);
        }