// Use this for initialization
    void Start()
    {
        detector = GameObject.Find("BeatDetector").GetComponent <BeatDetector>();
        detector.Initialize(audio.clip);

        detector.SynchAndPlay(audio);
    }
示例#2
0
        public FormMain()
        {
            InitializeComponent();
            Application.ApplicationExit += Application_ApplicationExit;

            // Initialize BeatDetector
            beatDetector = new BeatDetector();
            beatDetector.BeatDetected += BeatDetector_BeatDetected;
            beatDetector.BpmDetected  += BeatDetector_BpmDetected;

            // Initialize WASAPI
            try
            {
                wasapi = new WasapiLoopbackCapture();
                wasapi.DataAvailable += Wasapi_DataAvailable;
                wasapi.Initialize();
                wasapi.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\nThe application will now exit.", "WASAPI error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(0);
                return;
            }

            Timer t = new Timer();

            t.Tick    += T_Tick;
            t.Interval = 16;
            t.Start();
        }
    // Use this for initialization
    void Start()
    {
        detector = GameObject.Find("BeatDetector").GetComponent<BeatDetector>();
        detector.Initialize(audio.clip);

        detector.SynchAndPlay(audio);
    }
示例#4
0
 public void LoadSong(Uri fileLocation, string songName)
 {
     //Uri songUri = new Uri(fileLocation.OriginalString + "/music.mp3", UriKind.Relative);
     //Music = Song.FromUri(songName, songUri);
     Music = BeatDetector.Instance();
     Music.loadSystem();
     Music.LoadSong(1024, fileLocation.OriginalString + "/music.mp3");
 }
示例#5
0
    // Use this for initialization
    void Start()
    {
        _playedAudio = GameObject.Find("TrackPlayer").GetComponent <AudioSource>();


        _beatDetector = GetComponent <BeatDetector>();
        _beatDetector.Initialize(_playedAudio.clip);
        _beatDetector.SynchAndPlay(GameObject.Find("TrackPlayer").audio);
    }
        private void DrawData(double[] data, Graphics g, Converter cvter)
        {
            var chkpoint2 = DateTime.Now;

            if (data == null || data.Length == 0 || sourceData == null)
            {
                return;
            }

            float ratioFreq     = (float)panel1.Width / (float)data.Length;;
            float ratioFreqTest = (float)panel1.Width / 200;
            float ratioWave     = (float)panel1.Width / (float)sourceData.Length;
            float value         = 0;


            gTempBuffer.DrawImage(mainBuffer, new Rectangle(0, 0, tempBuffer.Width, tempBuffer.Height), 0, 0, mainBuffer.Width, mainBuffer.Height, GraphicsUnit.Pixel);

            //BitmapFilter.GaussianBlur(mainBuffer as Bitmap, 5);

            gMainBuffer.DrawImage(tempBuffer, new Rectangle(-2, -1, mainBuffer.Width + 4, mainBuffer.Height + 3), 0, 0, tempBuffer.Width, tempBuffer.Height, GraphicsUnit.Pixel, imgAttribute);


            int sx, sy;

            for (int i = 0; i < data.Length; i++)
            {
                cvter.FromReal(i * ratioFreq, 0, out sx, out sy);
                value = (float)(data[i] * cvt.MaxScaledY);
                gMainBuffer.FillRectangle(Constants.Brushes.redLightBrush, i * ratioFreq, sy, ratioFreq - 1, value / 2);
            }


            for (int i = 0; i < sourceData.Length - 4; i += 4)
            {
                cvter.FromReal(i * ratioWave, 0, out sx, out sy);
                gMainBuffer.DrawLine(new Pen(Constants.Brushes.blueBrush), new PointF(i * ratioWave, sy - (int)(sourceData[i] * 150 * MasterScaleFFT) + 2), new PointF((i + 4) * ratioWave, sy - (int)(sourceData[i + 4] * 150 * MasterScaleFFT) + 2));
            }

            g.DrawImage(mainBuffer, new Point(0, 0));


            for (int i = 0; i < data.Length; i++)
            {
                cvter.FromReal(i * ratioFreq, 0, out sx, out sy);
                value = (float)(data[i] * cvt.MaxScaledY);
                g.FillRectangle(Constants.Brushes.redBrush, i * ratioFreq, sy - value / 2, ratioFreq - 1, value / 2);
            }

            #region BeatDetector (Don't know what will to, just code)
            double newBass = 0, accumBass = 0;
            bool   beatDetected = BeatDetector.Scan(data, 6, 13, ref accumBass, ref newBass);
            #endregion

            osdPanel.AddSet("Drawing delay(ms):", DateTime.Now.Subtract(chkpoint2).TotalMilliseconds.ToString());
        }
示例#7
0
    void Start()
    {
        audioSource.Play();

        bd    = new BeatDetector(1024);
        cubes = GameObject.FindGameObjectsWithTag("cube");

        string songJson = System.IO.File.ReadAllText("Assets/Resources/songData/" + audioSource.clip.name + ".dat");

        songData = JsonUtility.FromJson <SongData>(songJson);
    }
        public void ApplyModel()
        {
            var songFilePath       = @"C:\Users\Jan\Music\Dimitri Vegas - Ocarina.mp3";
            var sut                = new BeatDetector();
            var signal             = AudioSampleReader.ReadMonoSamples(songFilePath, out var sampleRate);
            var beatDetectorResult = sut.DetectBeats(signal, sampleRate);

            Console.WriteLine($@"BPM: {beatDetectorResult.BeatsPerMinute:F0}");
            foreach (var beat in beatDetectorResult.DetectedBeats)
            {
                Console.WriteLine($@"{beat.SampleIndex};{beat.Strength}");
            }
        }
示例#9
0
        private void Start_Click(object sender, EventArgs e)
        {
            if (songs.Text == "")
            {
            }
            else
            {
                //set difficulty
                SetDifficulty(difficulty.Text);
                delay = (280 / gamespeed);


                //create a new instance of beat detector and load FMOD system
                detector = BeatDetector.Instance();
                detector.loadSystem();

                //load song in array
                detector.LoadSong(1024, songPaths[currentSongIndex]);

                //delay spawn to time beats
                detector.loadSongToDelay(delay);

                //start the song
                detector.setStarted(true);

                //start gravity timer
                gravity.Enabled = true;
                gravity.Start();

                //hide main menu UI
                start.Visible      = false;
                songs.Visible      = false;
                loadSongs.Visible  = false;
                difficulty.Visible = false;
                topEU.SendToBack();



                //show in-game UI
                DisplayScore();
                SetHitField();
                SetHitBar();
                highScore.Visible    = true;
                scoreDisplay.Visible = true;
                NowPlaying();
                np.Visible = true;
                np.Text    = "Now Playing:\n" + songs.Text;
                Focus();
            }
        }
        private void InitSoundCapture()
        {
            endingNode = dataList;

            waveInStream = new WaveIn();
            waveInStream.NumberOfBuffers    = 5;
            waveInStream.BufferMilliseconds = 10;
            waveInStream.WaveFormat         = new WaveFormat(samplingFrequency, 1);
            waveInStream.DataAvailable     += new EventHandler <WaveInEventArgs>(waveInStream_DataAvailable);
            waveInStream.StartRecording();

            Mode           = 1;
            MasterScaleFFT = 1;
            DropOffScale   = 0.4;
            N_FFT          = 2048;

            BeatDetector.InitDetector(50);
        }
 public static void OpenWindow(BeatDetector detector)
 {
     window          = GetWindow <SpectogramWindow>();
     window.detector = detector;
 }
 public static void OpenWindow(BeatDetector detector)
 {
     window = GetWindow<SpectogramWindow>();
     window.detector = detector;
 }
    // Use this for initialization
    void Start()
    {
        _playedAudio = GameObject.Find("TrackPlayer").GetComponent<AudioSource>();

        _beatDetector = GetComponent<BeatDetector>();
        _beatDetector.Initialize( _playedAudio.clip );
        _beatDetector.SynchAndPlay(GameObject.Find("TrackPlayer").audio);
    }
示例#14
0
    void Start()
    {
        BeatDetector processor = FindObjectOfType <BeatDetector> ();

        processor.AddAudioCallback(this);
    }
示例#15
0
 public static BeatReporter GetReporterInstance(BeatDetector detector)
 {
     return(myself ?? (myself = new BeatReporter(detector)));
 }
示例#16
0
 private BeatReporter(BeatDetector detector)
 {
     this.detector = detector;
 }
 void Start()
 {
     //here you tell the beat detector which function it should call
     detector = GameObject.Find("BeatDetector").GetComponent <BeatDetector>();
     detector.AddBeatListener(ChangeColor, band);
 }
 void OnEnable()
 {
     detector = (BeatDetector)target;
 }
示例#19
0
 public SongGenerator(SongGeneratorSettings settings)
 {
     beatDetector = new BeatDetector();
     levelInstructionGenerator = new LevelInstructionGenerator(settings);
 }
 void OnEnable()
 {
     detector = (BeatDetector)target;
 }
 void Start()
 {
     //here you tell the beat detector which function it should call
     detector = GameObject.Find("BeatDetector").GetComponent<BeatDetector>();
     detector.AddBeatListener(ChangeColor, band);
 }