public SpectrumVisualizer(int width, int height, string title, SpectrumAnalyzer _analyzer, SpectrumWave[] waves, TextureManager txtmanager, float[] offset) : base(width, height, new GraphicsMode(new ColorFormat(8, 8, 8, 0), 24, 8, 4), title)
        {
            VSync = VSyncMode.On;

            Width  = width;
            Height = height;

            Title = title;

            _analyzer.multiplier = height / 4;

            Analyzer = _analyzer;

            Replay = new SpectrumReplay(9);

            Waves = waves;

            /*
             * for(int i = 0; i < Waves.Length; i++)
             * {
             *  Waves[i].DegreesIncrement = 180f / (Analyzer._lines - 1);
             * }
             */

            Textures = txtmanager;

            Textures.LoadBackgrounds(Width, Height);

            LogoTexture = TextureManager.LoadTexture(ConfigManager.configDirectoryPath + @"\Particles\Logo.png");

            LogoOffset = offset;
        }
Пример #2
0
        public MusicPlayer()
        {
            InitializeComponent();

            NAudioSimpleEngine.Instance.PropertyChanged += NAudioSimpleEngine_PropertyChanged;
            SpectrumAnalyzer.RegisterSoundPlayer(NAudioSimpleEngine.Instance);
        }
Пример #3
0
        public void Update()
        {
            if (App.Current == null)
            {
                return;
            }

            if (SpectrumAnalyzer == null)
            {
                return;
            }

            // Dispatcher.Invoke(new Action(() =>
            App.Current.Dispatcher.Invoke((Action) delegate
            {
                _updating = true;
                // double start = TransformToChartSamples(Shift - Bandwidth / 2);
                // double end = TransformToChartSamples(Shift + Bandwidth / 2);
                double start = Shift - Bandwidth / 2;
                double end   = Shift + Bandwidth / 2;
                SpectrumAnalyzer.SetBandwidth(start, end);

                SpectrumAnalyzer.SetFrequencyIntervals(StartFrequency, StopFrequency, Precision);
                // SpectrumAnalyzer.SetVisibleFrequencyIntervals();
                _updating = false;
            });
        }
Пример #4
0
    private void Start()
    {
        audioController = GameObject.Find("AudioController");

        //Get audio sources from AudioController in scene
        mutedSource   = audioController.GetComponent <AudioAnalyzer>().mutedAudioSource;
        unmutedSource = audioController.GetComponent <AudioAnalyzer>().unmutedAudioSource;
        //Get spectrum analyzer from AudioController
        spectrumAnalyzer = audioController.GetComponent <AudioAnalyzer>().spectrumAnalyzer;

        //Find time-stamp of the first peak (ie time of the first obstacle)
        float time = 0f;

        for (int i = 0; i < spectrumAnalyzer.spectralFluxSamples.Count; ++i)
        {
            if (spectrumAnalyzer.spectralFluxSamples[i].isPeak)
            {
                time = spectrumAnalyzer.spectralFluxSamples[i].time;
                break;
            }
        }

        //Calculate distance between player and spawner to calculate offset
        float distance = Vector3.Distance(transform.position, playerPosition.transform.position);

        //Now calculate time offset based on projectile speed and distance between
        //The time of the first beat must be slightly shorter because of lag
        timeOffset = (distance / sharkPrefab.GetComponent <Projectile>().speed) + (time * 0.85f);

        nthSpawn = false;
        played   = false;
    }
Пример #5
0
 void Start()
 {
     oldColor = this.GetComponent <MeshRenderer>().material.color;
     //childRend = this.transform.GetComponentInChildren<ChildRenderer>();
     specAny = Camera.main.GetComponent <SpectrumAnalyzer>();
     //meshRend = GetComponent<MeshRenderer>();
 }
Пример #6
0
    private void Start()
    {
        //Get audio samples from all channels
        multiChannelSamples = new float[audioSource.clip.samples * audioSource.clip.channels];
        numberOfChannels    = audioSource.clip.channels;
        totalSamples        = audioSource.clip.samples;
        songTime            = audioSource.clip.length;

        //Store the clip's sampling rate
        sampleRate = audioSource.clip.frequency;

        //Remove existing spectral flux data
        foreach (FrequencyBand band in frequencyBandBoundaries)
        {
            band.Reset();
        }

        //Preprocess entire audio clip
        analyzer = new SpectrumAnalyzer(spectrumSampleSize, sampleRate, thresholdWindowSize, frequencyBandBoundaries.ToArray(), numberOfBars);

        //Retrieve sample data from clip
        audioSource.clip.GetData(multiChannelSamples, 0);

        ProcessFullSpectrum();

        //Visuallise processed audio
        visualiser.GenerateVisualiserFromSamples(analyzer.frequencyBands, audioSource.clip.length);
        audioSource.Play();
    }
Пример #7
0
    private void Start()
    {
        //Get components
        audioController  = GameObject.Find("AudioController");
        audioAnalyzer    = audioController.GetComponent <AudioAnalyzer>();
        spectrumAnalyzer = audioController.GetComponent <AudioAnalyzer>().spectrumAnalyzer;

        Vector3 topLeft       = getScreenTopLeft();
        Vector3 bottomRight   = getScreenBottomRight();
        float   screenXlength = bottomRight.x - topLeft.x;

        //Generate new wave
        GameObject floor = new GameObject("floor");

        floor.AddComponent <MeshRenderer>();
        floor.AddComponent <MeshFilter>();
        floor.AddComponent <MeshCollider>();
        floor.AddComponent <floor>();
        floor.GetComponent <MeshFilter>().mesh = CreatePlaneMesh();
        floor.GetComponent <MeshFilter>().mesh.SetVertices(vertexList);
        floor.GetComponent <MeshRenderer>().material   = floorMaterial;
        floor.GetComponent <MeshCollider>().sharedMesh = floor.GetComponent <MeshFilter>().mesh;

        floor.transform.position = new Vector3(topLeft.x + screenXlength / 2, 0, 0);
        previousFrameGameObject  = floor;
    }
Пример #8
0
 // Use this for initialization
 void Start()
 {
     //musicLoader = Camera.main.GetComponent<MusicLoad> ();
     songName   = GameObject.FindGameObjectWithTag("NAME").GetComponent <Text> ();
     playButton = GameObject.FindGameObjectWithTag("PLAY").GetComponent <Text> ();
     specAny    = Camera.main.GetComponent <SpectrumAnalyzer> ();
 }
Пример #9
0
        public void RealExampleDChord()
        {
            var spectrumAnalyser = new SpectrumAnalyzer();

            float[] fft = new float[4096];

            SetFrequenceLevel(fft, 290.70f, 0.203f);    //D4
            SetFrequenceLevel(fft, 441.43f, 0.685f);    //A4
            SetFrequenceLevel(fft, 592.16f, 0.456f);    //D5
            SetFrequenceLevel(fft, 742.90f, 0.339f);    //F#5
            SetFrequenceLevel(fft, 882.86f, 0.9000f);   //A5 (harmonics)
            SetFrequenceLevel(fft, 1184.33f, 0.291f);   //D6 (harmonics)
            SetFrequenceLevel(fft, 1324.29f, 0.650f);   //E6 (harmonics)
            SetFrequenceLevel(fft, 1485.79f, 0.380f);   //F#6 (harmonics)
            SetFrequenceLevel(fft, 1765.72f, 0.166f);   //A6 (harmonics)
            SetFrequenceLevel(fft, 2217.92f, 0.460f);   //C#7 (harmonics)
            SetFrequenceLevel(fft, 2357.89f, 0.403f);   //D7 (harmonics)
            SetFrequenceLevel(fft, 2960.82f, 0.435f);   //F#7 (harmonics)
            SetFrequenceLevel(fft, 3703.71f, 0.297f);   //A#7 (harmonics)

            List <IMusicalNote> notes = spectrumAnalyser.GetMusicalNotes(fft);

            spectrumAnalyser.DeleteUnusefulNotes(ref notes);

            Assert.AreEqual(6, notes.Count);

            Assert.AreEqual("D4", notes[0].ToString());
            Assert.AreEqual("A4", notes[1].ToString());
            Assert.AreEqual("D5", notes[2].ToString());
            Assert.AreEqual("Gb5", notes[3].ToString());
            Assert.AreEqual("A5", notes[4].ToString());
            Assert.AreEqual("D6", notes[5].ToString());
        }
Пример #10
0
        private void SetNotchBands()
        {
            SpectrumAnalyzer.Notch(_notchState);

            var halfBand = _notchBandwidth / 2;

            SpectrumAnalyzer.SetNotch(_notchFrequency - halfBand, _notchFrequency + halfBand);
        }
Пример #11
0
 // Use this for initialization
 void Start()
 {
     calm = 0;
     specAny = GetComponent<SpectrumAnalyzer> ();
     audioPlayer = Camera.main.GetComponent<AudioSource> ();
     audioInput = GetComponent<SpectrumAnalyzer> ();
     currentFocusState = FocalStates.NotFocusing;
     toggle = GameObject.FindGameObjectWithTag("ManToggle").GetComponent<Toggle>();
 }
Пример #12
0
        public void EmptyFFT()
        {
            var spectrumAnalyser = new SpectrumAnalyzer();

            float[] fft = new float[4096];

            List <IMusicalNote> notes = spectrumAnalyser.GetMusicalNotes(fft);

            Assert.AreEqual(0, notes.Count);
        }
Пример #13
0
        public SoundEngine()
        {
            // Initialize fmod system
              this.Verify(FMOD.Factory.System_Create(ref fmodSystem));
              this.Verify(fmodSystem.init(NUM_MAX_CHANNELS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero));

              this.analyzer = new SpectrumAnalyzer();

              this.subscribers = new List<Action<uint>>();
        }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     //musicLoader = Camera.main.GetComponent<MusicLoad> ();
     specAny = GetComponent<SpectrumAnalyzer> ();
     FeedBackeReader = GetComponent<FeedBackController> ();
     //		songName = GameObject.FindGameObjectWithTag ("NAME").GetComponent<Text> ();
     //		playButton = GameObject.FindGameObjectWithTag ("PLAY").GetComponent<Text> ();
     //		textBox = GameObject.FindGameObjectWithTag ("TEXT").GetComponent<Text> ();
     calmSlider =  GameObject.FindGameObjectWithTag ("UI_Canvas").GetComponentInChildren<Slider> ();
 }
Пример #15
0
    void Start()
    {
        specAny = GameObject.FindGameObjectWithTag("GameController").GetComponent<SpectrumAnalyzer>();

        if (!specAny.musicMode) {
            Application.runInBackground = true;
            GetComponent<AudioSource> ().clip = Microphone.Start (null, true, 1, 44100);
            GetComponent<AudioSource> ().loop = true; // Set the AudioClip to loop
            //GetComponent<AudioSource> ().mute = true; // Mute the sound, we don't want the player to hear it
            //while (!(Microphone.GetPosition(AudioInputDevice) > 0)){} // Wait until the recording has started
            GetComponent<AudioSource> ().Play (); // Play the audio source!
        }
    }
Пример #16
0
        public void LowCutTest()
        {
            var spectrumAnalyser = new SpectrumAnalyzer();

            float[] fft = new float[4096];

            SetFrequenceLevel(fft, 96.8f, 0.1f); //freq < 96,89941Hz
            SetFrequenceLevel(fft, 96.9f, 0.1f); //freq > 96,89941Hz

            List <IMusicalNote> notes = spectrumAnalyser.GetMusicalNotes(fft);

            Assert.AreEqual(1, notes.Count);
        }
Пример #17
0
 public static ANALYZER_RESULT Analysis(List <double> wl, List <double> counts, out List <PeakDetectInfo> peaks)
 {
     peaks = new List <PeakDetectInfo>();
     try
     {
         SpectrumAnalyzer analyzer = new SpectrumAnalyzer(wl, counts);
         var result = analyzer.Test(out peaks);
         return(result);
     } catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(ANALYZER_RESULT.ERROR);
 }
Пример #18
0
        public void A4AtNoiseLevel()
        {
            var spectrumAnalyser = new SpectrumAnalyzer();

            float[] fft = new float[4096];

            SetFrequenceLevel(fft, 440.0f, 0.0249f); //A4 - just noise (level too low)
            SetFrequenceLevel(fft, 880.0f, 0.025f);  //A5 - valid

            List <IMusicalNote> notes = spectrumAnalyser.GetMusicalNotes(fft);

            Assert.AreEqual(1, notes.Count);
            Assert.AreEqual("A5", notes[0].ToString());
        }
Пример #19
0
        public AFProcessor(ISharpControl control)
        {
            _control = control;
            _control.PropertyChanged += NotifyPropertyChangedHandler;
            Enabled = true;

            #region FFT Timer

            _fftTimer          = new System.Windows.Forms.Timer();
            _fftTimer.Tick    += fftTimer_Tick;
            _fftTimer.Interval = FFTTimerInterval;
            _fftBins           = FFTBins;

            #endregion

            #region FFT Buffers / Window

            InitFFTBuffers();
            BuildFFTWindow();

            #endregion

            #region Display component

            _spectrumAnalyzer                         = new SpectrumAnalyzer();
            _spectrumAnalyzer.Dock                    = DockStyle.Fill;
            _spectrumAnalyzer.Margin                  = new Padding(0, 0, 0, 0);
            _spectrumAnalyzer.DisplayRange            = 90;
            _spectrumAnalyzer.EnableFilter            = false;
            _spectrumAnalyzer.EnableHotTracking       = false;
            _spectrumAnalyzer.EnableFrequencyMarker   = false;
            _spectrumAnalyzer.StepSize                = 5000;
            _spectrumAnalyzer.UseSmoothing            = true;
            _spectrumAnalyzer.SpectrumWidth           = Utils.GetIntSetting("minOutputSampleRate", 32000) / 2;
            _spectrumAnalyzer.Frequency               = _spectrumAnalyzer.SpectrumWidth / 2;
            _spectrumAnalyzer.CenterFrequency         = _spectrumAnalyzer.SpectrumWidth / 2;
            _spectrumAnalyzer.Attack                  = 0.9f;
            _spectrumAnalyzer.Decay                   = 0.6f;
            _spectrumAnalyzer.StatusText              = "Linear Interpolated Basis Function"; //EDIT: changed spectrum alanyzer window title to match wavelet fn
            _spectrumAnalyzer.FrequencyChanged       += spectrumAnalyzer_FrequencyChanged;
            _spectrumAnalyzer.CenterFrequencyChanged += spectrumAnalyzer_CenterFrequencyChanged;
            _spectrumAnalyzer.VisibleChanged         += spectrumAnalyzer_VisibleChanged;

            #endregion

            _control.RegisterStreamHook(this, ProcessorType.FilteredAudioOutput);
            _control.RegisterFrontControl(_spectrumAnalyzer, (PluginPosition)Utils.GetIntSetting("zoomPosition", (int)PluginPosition.Bottom));
        }
Пример #20
0
        public IFProcessor(ISharpControl control)
        {
            _control = control;
            _control.PropertyChanged += NotifyPropertyChangedHandler;
            Enabled = true;

            #region FFT Timer

            _fftTimer          = new System.Windows.Forms.Timer();
            _fftTimer.Tick    += fftTimer_Tick;
            _fftTimer.Interval = FFTTimerInterval;
            _fftBins           = FFTBins;

            #endregion

            #region FFT Buffers / Window

            InitFFTBuffers();
            BuildFFTWindow();

            #endregion

            #region Display component

            _spectrumAnalyzer                         = new SpectrumAnalyzer();
            _spectrumAnalyzer.Dock                    = DockStyle.Fill;
            _spectrumAnalyzer.Margin                  = new Padding(0, 0, 0, 0);
            _spectrumAnalyzer.DisplayRange            = 130;
            _spectrumAnalyzer.EnableFilter            = false;
            _spectrumAnalyzer.EnableHotTracking       = false;
            _spectrumAnalyzer.EnableSideFilterResize  = true;
            _spectrumAnalyzer.EnableFilterMove        = false;
            _spectrumAnalyzer.BandType                = BandType.Center;
            _spectrumAnalyzer.StepSize                = 1000;
            _spectrumAnalyzer.UseSmoothing            = true;
            _spectrumAnalyzer.Attack                  = 0.9f;
            _spectrumAnalyzer.Decay                   = 0.6f;
            _spectrumAnalyzer.StatusText              = "IF Spectrum";
            _spectrumAnalyzer.FrequencyChanged       += spectrumAnalyzer_FrequencyChanged;
            _spectrumAnalyzer.CenterFrequencyChanged += spectrumAnalyzer_CenterFrequencyChanged;
            _spectrumAnalyzer.BandwidthChanged       += spectrumAnalyzer_BandwidthChanged;
            _spectrumAnalyzer.VisibleChanged         += spectrumAnalyzer_VisibleChanged;

            #endregion

            _control.RegisterStreamHook(this, ProcessorType.DecimatedAndFilteredIQ);
            _control.RegisterFrontControl(_spectrumAnalyzer, (PluginPosition)Utils.GetIntSetting("zoomPosition", (int)PluginPosition.Bottom));
        }
Пример #21
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     //
     LoadApplicationSettings();
     //
     //之所以放在这个加载配置过程之后,是因为可能spectrum没有得到配置信息就已经初始化完了。那样保存的配置就无效。
     if (bassPlayer != null && showSpectrum)
     {
         SpectrumAnalyzer.RegisterSoundPlayer(bassPlayer);
     }
     nowLyricTextBlock.Foreground = GetBrushFromString(unplayedForecolor.ToString());
     preLyricTextBlock.Foreground = nowLyricTextBlock.Foreground;
     //
     //ShowWindowWithAnimation();
     //ScrollTextBlock(nowPlayingSong);
 }
Пример #22
0
        public void ChordWithHarmonics()
        {
            List <IMusicalNote> notes = new List <IMusicalNote>();

            notes.Add(new MusicalNote("A3", 0.04f));  //0
            notes.Add(new MusicalNote("A4", 0.08f));  //1
            notes.Add(new MusicalNote("A5", 0.02f));  //2

            var spectrumAnalyser = new SpectrumAnalyzer();

            spectrumAnalyser.SortMusicalNotesByVolume(ref notes);

            Assert.AreEqual("A4", notes[0].ToString());
            Assert.AreEqual("A3", notes[1].ToString());
            Assert.AreEqual("A5", notes[2].ToString());
        }
Пример #23
0
        public void OneNote_A4()
        {
            var spectrumAnalyser = new SpectrumAnalyzer();

            float[] fft = new float[4096];

            var level = 0.1f;

            SetFrequenceLevel(fft, 440.0f, level);

            List <IMusicalNote> notes = spectrumAnalyser.GetMusicalNotes(fft);

            Assert.AreEqual(1, notes.Count);
            Assert.AreEqual("A4", notes[0].ToString());
            Assert.AreEqual(level, notes[0].Volume);
        }
Пример #24
0
        void Calibrate()
        {
            List <double> wl     = _phosSpectra[(int)(CurrentSpectraItem - 1)].Spectrum.Select(p => p.X).ToList();
            List <double> counts = _phosSpectra[(int)(CurrentSpectraItem - 1)].Spectrum.Select(p => p.Y).ToList();

            SpectrumAnalyzer analyzer = new SpectrumAnalyzer(wl, counts);
            string           error;

            if (!analyzer.AutoCalibrate(out error))
            {
                MessageBox.Show(error, "Calibration failed, try another spectrum");
                return;
            }

            RamanAnalyzer.Analysis(wl, counts);
        }
Пример #25
0
        public void ChordWithLowLevelHarmonics()
        {
            List <IMusicalNote> notes = new List <IMusicalNote>();

            notes.Add(new MusicalNote("A3", 0.0001f)); //low level (less then 1/10 of the greatest => will be ingored)
            notes.Add(new MusicalNote("A4", 0.0010f));
            notes.Add(new MusicalNote("A5", 0.0011f));

            var spectrumAnalyser = new SpectrumAnalyzer();

            spectrumAnalyser.DeleteUnusefulNotes(ref notes);

            Assert.AreEqual(2, notes.Count);
            Assert.AreEqual("A4", notes[0].ToString());
            Assert.AreEqual("A5", notes[1].ToString());
        }
Пример #26
0
    public void ReprocessSong()
    {
        audioSource.Pause();

        foreach (FrequencyBand band in frequencyBandBoundaries)
        {
            band.Reset();
        }

        analyzer = new SpectrumAnalyzer(spectrumSampleSize, sampleRate, thresholdWindowSize, frequencyBandBoundaries.ToArray(), numberOfBars);
        audioSource.clip.GetData(multiChannelSamples, 0);
        ProcessFullSpectrum();

        visualiser.GenerateVisualiserFromSamples(analyzer.frequencyBands, audioSource.clip.length);

        audioSource.Play();
    }
Пример #27
0
    public override void Init()
    {
        if (_hasInit)
        {
            return;
        }
        base.Init();
        _spectrumAnalyzer  = GameObject.Find(Constants.AbjectAudioInputs).GetComponent <SpectrumAnalyzer>();
        _audioLevelTracker = GameObject.Find(Constants.AbjectAudioInputs).GetComponent <AudioLevelTracker>();
        _mainIcon          = GameObject.Find("MainIcon").GetComponent <SpriteRenderer>();
        _singleTapSpawn    = GameObject.Find("SingleTapSpawn").transform;
        _customTapSpawn    = GameObject.Find("CustomTapSpawn").transform;
        _heldSpawn         = GameObject.Find("HeldSpawn").transform;
        _timeHeldSpawn     = GameObject.Find("TimeHeldSpawn").transform;

        //PlayerPrefs
        _lastSavedDeviceName  = PlayerPrefHelper.GetLastSavedDeviceDefault();
        _currentChannel       = PlayerPrefHelper.GetCurrentChannel();
        HzOffset              = PlayerPrefHelper.GetHzOffset();
        RequiredFrames        = PlayerPrefHelper.GetRequiredFrames();
        PeaksPriority         = PlayerPrefHelper.GetPeaksPriority();
        HeldReset             = PlayerPrefHelper.GetHeldReset();
        SingleTapReset        = PlayerPrefHelper.GetSingleTapReset();
        _levelDynamicRange    = PlayerPrefHelper.GetLevelDynamicRange();
        _levelGain            = PlayerPrefHelper.GetLevelGain();
        _spectrumDynamicRange = PlayerPrefHelper.GetSpectrumDynamicRange();
        _spectrumGain         = PlayerPrefHelper.GetSpectrumGain();
        SpectrumThreshold     = PlayerPrefHelper.GetSpectrumThreshold();

        //FieldsData
        _idData                   = Helper.GetFieldData("Id");
        _channelData              = Helper.GetFieldData("Channel");
        _hzOffsetData             = Helper.GetFieldData("HzOffset");
        _requiredFramesData       = Helper.GetFieldData("RequiredFrames");
        _peaksPriorityData        = Helper.GetFieldData("PeaksPriority");
        _heldResetData            = Helper.GetFieldData("HeldReset");
        _singleTapResetData       = Helper.GetFieldData("TapReset");
        _levelDynamicRangeData    = Helper.GetFieldData("LevelDynamicRange");
        _levelGainData            = Helper.GetFieldData("LevelGain");
        _spectrumDynamicRangeData = Helper.GetFieldData("SpectrumDynamicRange");
        _spectrumGainData         = Helper.GetFieldData("SpectrumGain");
        _spectrumThresholdData    = Helper.GetFieldData("SpectrumThreshold");

        Devices  = AudioSystem.InputDevices;
        _hasInit = true;
    }
Пример #28
0
        public void CalculateNoteFrequence()
        {
            var spectrumAnalysis = new SpectrumAnalyzer();

            Assert.AreEqual(440.0.ToString("####0.00"), NoteToFrequenceTable.Instance["A4"].ToString("####0.00"));
            Assert.AreEqual(523.25.ToString("####0.00"), NoteToFrequenceTable.Instance["C5"].ToString("####0.00"));
            Assert.AreEqual(2959.96.ToString("####0.00"), NoteToFrequenceTable.Instance["F#7"].ToString("####0.00"));
            Assert.AreEqual(2959.96.ToString("####0.00"), NoteToFrequenceTable.Instance["Gb7"].ToString("####0.00"));
            Assert.AreEqual(116.54.ToString("####0.00"), NoteToFrequenceTable.Instance["Bb2"].ToString("####0.00"));
            Assert.AreEqual(4698.64.ToString("####0.00"), NoteToFrequenceTable.Instance["D8"].ToString("####0.00"));

            Assert.AreEqual(NoteToFrequenceTable.Instance["Db7"], NoteToFrequenceTable.Instance["C#7"]);
            Assert.AreEqual(NoteToFrequenceTable.Instance["Eb7"], NoteToFrequenceTable.Instance["D#7"]);
            Assert.AreEqual(NoteToFrequenceTable.Instance["Gb7"], NoteToFrequenceTable.Instance["F#7"]);
            Assert.AreEqual(NoteToFrequenceTable.Instance["Ab7"], NoteToFrequenceTable.Instance["G#7"]);
            Assert.AreEqual(NoteToFrequenceTable.Instance["Bb7"], NoteToFrequenceTable.Instance["A#7"]);
        }
        public CSharpNationManager()
        {
            InitializeComponent();

            windowManager = new WindowManager();

            ChangeWindows(windowManager.GetWaveWindow());

            VisualizerThread = new Thread(VisualizerProcess);
            Analyzer         = new SpectrumAnalyzer();

            DevicesCb.ItemsSource = Analyzer.GetDevices();

            if (DevicesCb.HasItems)
            {
                DevicesCb.SelectedIndex = 0;
            }
        }
Пример #30
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            mouse.OnMouseActivity += new System.Windows.Forms.MouseEventHandler(mouse_OnMouseActivity);
            mouse.Start();

            worker = new BackgroundWorker();
            worker.WorkerReportsProgress      = true;
            worker.WorkerSupportsCancellation = true;
            worker.DoWork             += new DoWorkEventHandler(worker_DoWork);
            worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            worker.ProgressChanged    += new ProgressChangedEventHandler(worker_ProgressChanged);
            if (PlayController.bassEng != null)
            {
                SpectrumAnalyzer.RegisterSoundPlayer(PlayController.bassEng);
            }
            Win32InfoRegister();
            SpectrumAnalyzer.IsEnabled = false;
            InitTaskBar();
        }
    IEnumerator Spectrum()
    {
        float [] data = new float [song.samples * song.channels];
        song.GetData(data, 0);
        SpectrumAnalyzer sa = new SpectrumAnalyzer(data, song.length);

        sa.Run();
        sampleTime     = sa.sampleTime;
        bandBeats      = sa.bandBeats;
        beatTotalPower = sa.beatTotalPower;
        charPitches    = sa.charPitches;
        volumes        = sa.volumes;
        while (sa.done == false)
        {
            yield return(new WaitForSeconds(.05f));
        }

        yield return(StartCoroutine("Generate"));
    }
Пример #32
0
        private void FftAnalyzer_FftCalculated(object sender, FftEventArgs e)
        {
            FrequencyBins bin;

            // _spectrumAnalyzer.Clear();
            if (!VideoFilter)
            {
                bin = new FrequencyBins(e, _model.Radio.BinParametersDefault());
            }
            else
            {
                bin = new FrequencyBins(e,
                                        _model.Radio.BinParametersVideoFilter(_model.FftAnalyzer.FftLength, VideoPoints));
            }

            SpectrumAnalyzer.Update(bin);

            if (_model.Settings.AsyncAnalyze)
            {
                TaskUtility.Run(() => Analyze(e, bin));
            }
            else
            {
                Analyze(e, bin);
            }

            UpdateSquelch();

            if (AutoStep)
            {
                FrequencyStep = (uint)Math.Abs(MeterView.FrequencyErrorValue * 500000);
            }

            if (AfcState)
            {
                if (Math.Abs(MeterView.FrequencyErrorValue * 1000000) > _model.Settings.AfcThreshold) //1000 as default
                {
                    FrequencyValue = (uint)(MeterView.PeakFrequencyValue * 1000000);
                }
            }
            RecordingView.Tick();
        }
Пример #33
0
        /// <summary>
        /// Setup the spectrum analyzer
        /// </summary>
        public static void SetupSampleSource(ISampleSource aSampleSource)
        {
            FFTSize          = FftSize.Fft2048;
            SpectrumProvider = new BasicSpectrumProvider(aSampleSource.WaveFormat.Channels, aSampleSource.WaveFormat.SampleRate, FFTSize);

            m_SpectrumAnalyzer = new SpectrumAnalyzer(FFTSize)
            {
                SpectrumProvider = SpectrumProvider,
                UseAverage       = true,
                BarCount         = NumberOfAnalysisBars,
                UseLogScale      = true,
                ScalingStrategy  = ScalingStrategy.Sqrt
            };

            var notificationSource = new SingleBlockNotificationStream(aSampleSource);

            notificationSource.SingleBlockRead += (s, a) => SpectrumProvider.Add(a.Left, a.Right);

            m_Source = notificationSource.ToWaveSource(16);
        }
Пример #34
0
        public void NotesUnder3AreIgnored()
        {
            List <IMusicalNote> notes = new List <IMusicalNote>();

            notes.Add(new MusicalNote("C1", 0.01f));
            notes.Add(new MusicalNote("D1", 0.01f));
            notes.Add(new MusicalNote("C2", 0.01f));
            notes.Add(new MusicalNote("D2", 0.01f));
            notes.Add(new MusicalNote("A2", 0.01f));
            notes.Add(new MusicalNote("Bb2", 0.01f));
            notes.Add(new MusicalNote("B2", 0.01f));
            notes.Add(new MusicalNote("C3", 0.01f));

            var spectrumAnalyser = new SpectrumAnalyzer();

            spectrumAnalyser.DeleteUnusefulNotes(ref notes);

            Assert.AreEqual(1, notes.Count);
            Assert.AreEqual("C3", notes[0].ToString());
        }
        void DrawSpectrum(SpectrumAnalyzer.SpectrumSamples samples)
        {
            if (!_isInit)
            {
                _isInit = true;
                Init();
            }

            int count = samples.Data == null ? 0 : samples.Data.Count/2;

            //Label.Text = count.ToString();           

            int windowWidth = (int)Math.Round(SpectrumGraph.ActualWidth);

            double wholeStep = windowWidth;// samples.Data.Count / (double)(ConfigManager.ECGDeviceFrequensy / 2); // StepPerBeat;
            int delta = (int)Math.Round(_currentX + wholeStep - windowWidth);

            if (count > 0)
            {
                samples.Data = samples.Data.GetRange(1, samples.Data.Count - 1);

                double _start = 0;// _currentX;
                double dx = windowWidth / (double)count;
                if (delta > 0)
                {
                    int j = (int)((wholeStep - delta) / dx);

                    int[] points = new int[j * 2 + 4];
                    AddStartPoint(points);
                    FillPoints(points, 2, 0, j, samples.Data, dx);

                    double x = points[j * 2] + dx - windowWidth;
                    double converted = ConvertValue(samples.Data[j]);
                    double y = (converted - points[j * 2 + 1]) / dx * x + points[j * 2 + 1];

                    points[j * 2 + 2] = windowWidth;
                    points[j * 2 + 3] = (int)Math.Round(y);

                    DrawLines(points);
                    ClearImage();

                    if (AutoShift)
                    {
                        Max = (_maxY + _minY) / 2 + 1;
                        Min = (_maxY + _minY) / 2 - 1;
                        _maxY = _minY = samples.Data[j];
                    }


                    _currentX = 0;
                    points = new int[(samples.Data.Count - j + 1) * 2];
                    AddStartPoint(points);

                    FillPoints(points, 2, j, samples.Data.Count - j, samples.Data, dx);

                    DrawLines(points);
                    _currentX = delta;
                }
                else
                {
                    int[] points = new int[samples.Data.Count * 2 + 2];
                    AddStartPoint(points);
                    if (points[0] == 0)
                        _maxY = _minY = samples.Data[0];
                    FillPoints(points, 2, 0, samples.Data.Count, samples.Data, dx);
                    DrawLines(points);
                    _currentX = _start + wholeStep;
                }

            }
            else
            {
                int[] points = new int[4];
                AddStartPoint(points);
                if (delta > 0)
                {
                    points[2] = windowWidth;
                    points[3] = _currentY;
                    DrawLines(points);

                    ClearImage();

                    points[0] = 0;
                    points[2] = delta;
                    DrawLines(points);
                    _currentX = delta;
                }
                else
                {
                    points[2] = (int)Math.Round(_currentX + wholeStep);
                    points[3] = _currentY;
                    DrawLines(points);
                    _currentX = _currentX + wholeStep;
                }
            }
            int xBorder = (int)(windowWidth/(double)ConfigManager.ECGDeviceFrequensy*samples.Border);
            _bmp.DrawLine(xBorder, (int)_bmp.Height/3, xBorder, (int)_bmp.Height/3*2, Colors.Red);

                //OldClipRect.Rect = new Rect(_currentX, 0, SpectrumGraph.ActualWidth, SpectrumGraph.myGrid.RowDefinitions[0].ActualHeight);
        }