Exemplo n.º 1
0
        /// <summary>
        /// Beatの検出位置をListで返す
        /// </summary>
        /// <returns>Beat検出位置群</returns>
        public List <stBeatPos> GetBeatPositions()
        {
            #region [  BeatPosition格納リストの初期化 ]
            if (this.listBeatPositions != null)
            {
                this.listBeatPositions.Clear();
            }
            else
            {
                this.listBeatPositions = new List <stBeatPos>();
            }
            #endregion

            BPMBEATPROC _beatProc = new BPMBEATPROC(GetBeat_ProgressCallback);

            bool ret = BassFx.BASS_FX_BPM_BeatDecodeGet(
                this.hBassStream,
                0,
                nTotalSeconds,
                //0,
                BASSFXBpm.BASS_FX_BPM_DEFAULT,                          //BASSFXBpm.BASS_FX_BPM_MULT2,
                _beatProc,
                IntPtr.Zero);

            return(this.listBeatPositions);
        }
Exemplo n.º 2
0
 private void ClearUp()
 {
     if (this.FChannel != null)
     {
         if (this.FChannel.BassHandle.HasValue)
         {
             _beatProc = new BPMBEATPROC(MyBeatProc);
             BassFx.BASS_FX_BPM_BeatFree(this.FChannel.BassHandle.Value);
         }
     }
 }
Exemplo n.º 3
0
        private void Scan()
        {
            long pos = Bass.BASS_ChannelGetLength(this.handle);

            this.len  = Bass.BASS_ChannelBytes2Seconds(this.handle, pos);
            _beatProc = new BPMBEATPROC(MyBeatProc);

            BassFx.BASS_FX_BPM_BeatCallbackSet(this.handle, _beatProc, IntPtr.Zero);
            BassFx.BASS_FX_BPM_BeatSetParameters(this.handle, this.parameters.Width, this.parameters.Center, this.parameters.Release);
            BassFx.BASS_FX_BPM_BeatDecodeGet(this.handle, 0.0, this.len, BASSFXBpm.BASS_FX_BPM_BKGRND, _beatProc, IntPtr.Zero);


            Bass.BASS_StreamFree(this.handle);
            if (OnComplete != null)
            {
                OnComplete(this.parameters.Index);
            }
        }
Exemplo n.º 4
0
        private void Setup()
        {
            if (this.FChannel != null)
            {
                if (this.FChannel.BassHandle.HasValue)
                {
                    _beatProc = new BPMBEATPROC(MyBeatProc);
                    BassFx.BASS_FX_BPM_BeatCallbackSet(this.FChannel.BassHandle.Value, _beatProc, IntPtr.Zero);

                    double band, center, release;

                    this.FPinInBandWidth.GetValue(0, out band);
                    this.FPinInCenter.GetValue(0, out center);
                    this.FPinInRelease.GetValue(0, out release);

                    BassFx.BASS_FX_BPM_BeatSetParameters(this.FChannel.BassHandle.Value, (float)band, (float)center, (float)release);
                }
            }
        }
Exemplo n.º 5
0
        private void buttonPlay_Click(object sender, System.EventArgs e)
        {
            this.checkBoxSwap.Checked    = false;
            this.checkBoxFlanger.Checked = false;
            this.checkBoxEcho.Checked    = false;
            Bass.BASS_StreamFree(_StreamFX);
            if (_FileName != String.Empty)
            {
                // create the decoding stream
                _Stream = Bass.BASS_StreamCreateFile(_FileName, 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_PRESCAN);
                if (_Stream != 0)
                {
                    _20mslength = (int)Bass.BASS_ChannelSeconds2Bytes(_Stream, 0.02f);                     // 20ms window
                    // and start to get the BPM...BEFORE! playing
                    bpmProc = new BPMPROCESSPROC(MyBPMProc);
                    float bpm = BassFx.BASS_FX_BPM_DecodeGet(_Stream, 1f, 180f, Utils.MakeLong(50, 180), BASSFXBpm.BASS_FX_BPM_BKGRND | BASSFXBpm.BASS_FX_FREESOURCE | BASSFXBpm.BASS_FX_BPM_MULT2, bpmProc, IntPtr.Zero);
                    this.labelBPM.Text = String.Format("BPM={0}", bpm);

                    // and set the position back...so that we hear the playback from the beginning...
                    // never get the BPM from '_Stream' while playing...this will steel the data from the decoding channel
                    Bass.BASS_ChannelSetPosition(_Stream, 0);

                    // now we create a Tempo channel...the actual playing channel
                    _StreamFX = BassFx.BASS_FX_TempoCreate(_Stream, BASSFlag.BASS_FX_FREESOURCE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_SAMPLE_LOOP);
                }

                if (_StreamFX != 0 && Bass.BASS_ChannelPlay(_StreamFX, false))
                {
                    this.timerUpdate.Start();

                    // real-time beat position
                    beatProc = new BPMBEATPROC(MyBeatProc);
                    BassFx.BASS_FX_BPM_BeatCallbackSet(_StreamFX, beatProc, IntPtr.Zero);
                }
                else
                {
                    Console.WriteLine("Error = {0}", Bass.BASS_ErrorGetCode());
                }
            }
        }
Exemplo n.º 6
0
        public void Start(int deviceId)
        {
            Thread backgroundThread = new Thread(() =>
            {
                try
                {
                    _threadDispatcher = Dispatcher.CurrentDispatcher;
                    _threadDispatcher.BeginInvoke(new Action(() =>
                    {
                        // Wasapi only works on Vista, 7 and the likes
                        if (HasWasapi)
                        {
                            InitWasapi(deviceId);
                        }
                        else
                        {
                            Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_UPDATEPERIOD, 0);
                            Bass.BASS_Init(0, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
                            InitBassapi(deviceId);
                        }
                        _bpmBeatProc = new BPMBEATPROC(BpmBeatProc);

                        BassFx.BASS_FX_BPM_BeatCallbackSet(_recordChan, _bpmBeatProc, IntPtr.Zero);
                    }
                                                             ));
                    Dispatcher.Run();
                }
                catch (Exception e)
                {
                    App.ReportException(e);
                }
            });

            backgroundThread.IsBackground = true;
            backgroundThread.SetApartmentState(ApartmentState.STA);
            backgroundThread.Priority = ThreadPriority.BelowNormal;
            backgroundThread.Start();
        }
Exemplo n.º 7
0
 public static extern bool BASS_FX_BPM_BeatCallbackSet(int handle, BPMBEATPROC proc, IntPtr user);
Exemplo n.º 8
0
 public static extern bool BASS_FX_BPM_BeatDecodeGet(int channel, double startSec, double endSec, BASSFXBpm flags, BPMBEATPROC proc, IntPtr user);
Exemplo n.º 9
0
 public static extern bool BASS_FX_BPM_BeatDecodeGet(int channel, double startSec, double endSec, BASSFXBpm flags, BPMBEATPROC proc, IntPtr user);
Exemplo n.º 10
0
 public static extern bool BASS_FX_BPM_BeatCallbackSet(int handle, BPMBEATPROC proc, IntPtr user);
Exemplo n.º 11
0
 public static void BPM_BeatCallbackSet(int handle, BPMBEATPROC proc, IntPtr user)
 {
     if(!BassFx.BASS_FX_BPM_BeatCallbackSet(handle, proc, user))
         Base.CheckForError();
 }