Example #1
0
 public void Dispose()           // 使い終わったら必ずDispose()すること。BASSのリソースを握りっぱなしにすると、他の再生に不都合が生じるため。
 {
     BassFx.BASS_FX_BPM_Free(this.hBassStream);
     Bass.BASS_StreamFree(this.hBassStream);
     this.hBassStream = -1;
     Bass.BASS_Free();
 }
Example #2
0
        public override async Task <(bool Changed, SongData song)> Execute(SongData song)
        {
            int stream = Bass.BASS_StreamCreateFile(song.FullFileName, 0, 0, BASSFlag.BASS_STREAM_DECODE);

            if (stream == 0)
            {
                log.Error("BPM: Could not create stream for {0}. {1}", song.FullFileName, Bass.BASS_ErrorGetCode().ToString());
                return(false, song);
            }

            _bpmProc = BpmProgressProc;

            double len = Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream));
            float  bpm = BassFx.BASS_FX_BPM_DecodeGet(stream, 0.0, len, 0, BASSFXBpm.BASS_FX_BPM_BKGRND | BASSFXBpm.BASS_FX_FREESOURCE | BASSFXBpm.BASS_FX_BPM_MULT2,
                                                      _bpmProc, IntPtr.Zero);

            song.BPM = Convert.ToInt32(bpm);
            BassFx.BASS_FX_BPM_Free(stream);
            return(true, song);
        }