Exemplo n.º 1
0
        /// <summary>
        /// Register the Fade out Event
        /// </summary>
        /// <param name="stream"></param>
        /// <param name="fadeOutMS"></param>
        /// <returns></returns>
        private int RegisterCrossFadeEvent(int stream)
        {
            int    syncHandle     = 0;
            long   len            = Bass.BASS_ChannelGetLength(stream);          // length in bytes
            double totaltime      = Bass.BASS_ChannelBytes2Seconds(stream, len); // the total time length
            double fadeOutSeconds = 0;

            if (Config.CrossFadeIntervalMs > 0)
            {
                fadeOutSeconds = Config.CrossFadeIntervalMs / 1000.0;
            }

            long bytePos = Bass.BASS_ChannelSeconds2Bytes(stream, totaltime - fadeOutSeconds);

            syncHandle = Bass.BASS_ChannelSetSync(stream,
                                                  BASSSync.BASS_SYNC_POS,
                                                  bytePos, _playbackCrossFadeProcDelegate,
                                                  IntPtr.Zero);

            if (syncHandle == 0)
            {
                Log.Debug("BASS: RegisterCrossFadeEvent of stream {0} failed with error {1}", stream,
                          Enum.GetName(typeof(BASSError), Bass.BASS_ErrorGetCode()));
            }
            return(syncHandle);
        }
Exemplo n.º 2
0
        public double GetNowPosition()
        {
            var pos = Bass.BASS_ChannelGetPosition(playHandle);
            var now = Bass.BASS_ChannelBytes2Seconds(playHandle, pos);

            return(now);
        }
Exemplo n.º 3
0
        public static int getPosOfStream(int stream)//получение текущей позиции
        {
            long pos    = Bass.BASS_ChannelGetPosition(stream);
            int  posSec = (int)Bass.BASS_ChannelBytes2Seconds(stream, pos);

            return(posSec);
        }
Exemplo n.º 4
0
        //-----------------------------------------------------------------------------------------------
        //ファイルを再生する
        //-----------------------------------------------------------------------------------------------
        public bool PlaySound(string fileName, int vol = 255, bool isLoop = false, double second = 0)
        {
            StopSound();
            playHandle = GetHandle(fileName);

            //if ((Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_DEFAULT) & BASSFlag.BASS_SAMPLE_LOOP) == BASSFlag.BASS_SAMPLE_LOOP)
            if (isLoop == false)
            {
                // loop flag was set, so remove it
                Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_DEFAULT, BASSFlag.BASS_SAMPLE_LOOP);
            }
            else
            {
                // loop flag was not set, so set it
                Bass.BASS_ChannelFlags(playHandle, BASSFlag.BASS_SAMPLE_LOOP, BASSFlag.BASS_SAMPLE_LOOP);
            }

            Bass.BASS_ChannelPlay(playHandle, false);

//			int syncHandle = Bass.BASS_ChannelSetSync(playHandle, BASSSync.BASS_SYNC_END, 0, proc, IntPtr.Zero);
            //		if (syncHandle == 0) throw new InvalidOperationException("cannot set sync");

            Bass.BASS_ChannelSetPosition(playHandle, second);
            SetVolume(vol);
            //ret = Bass.BASS_ChannelGetLength(playHandle);
            m_length = Bass.BASS_ChannelBytes2Seconds(playHandle, Bass.BASS_ChannelGetLength(playHandle));

            return(true);
        }
        public float CurrentPositionInSeconds()
        {
            long   bytePos     = Bass.BASS_ChannelGetPosition(audioHandle);
            double elapsedtime = Bass.BASS_ChannelBytes2Seconds(audioHandle, bytePos);

            return((float)elapsedtime);
        }
Exemplo n.º 6
0
 async void Position_Change()
 {
     while (Visibility == Visibility.Visible)
     {
         if (!IsBusy)
         {
             if (Bass.BASS_ChannelIsActive(Stream) == BASSActive.BASS_ACTIVE_PLAYING && !IsLocationChanging)
             {
                 long position = Bass.BASS_ChannelGetPosition(Stream);
                 Location_S.Value = Bass.BASS_ChannelBytes2Seconds(Stream, position);
                 TimeSpan Time    = TimeSpan.FromSeconds(Location_S.Value);
                 string   Minutes = Time.Minutes.ToString();
                 string   Seconds = Time.Seconds.ToString();
                 if (Time.Minutes < 10)
                 {
                     Minutes = "0" + Time.Minutes;
                 }
                 if (Time.Seconds < 10)
                 {
                     Seconds = "0" + Time.Seconds;
                 }
                 Location_T.Text = Minutes + ":" + Seconds;
             }
             else if (Bass.BASS_ChannelIsActive(Stream) == BASSActive.BASS_ACTIVE_STOPPED && !IsLocationChanging && !IsPaused)
             {
                 Location_S.Value = 0;
                 Location_T.Text  = "00:00";
             }
         }
         await Task.Delay(1000 / 30);
     }
 }
Exemplo n.º 7
0
        public static int GetPositionOfStream(int stream)
        {
            long Pos    = Bass.BASS_ChannelGetPosition(stream);
            int  CurPos = (int)Bass.BASS_ChannelBytes2Seconds(stream, Pos);

            return(CurPos);
        }
Exemplo n.º 8
0
        public static int GetPosition(int stream)
        {
            long   pos    = Bass.BASS_ChannelGetPosition(stream);
            double posSec = Bass.BASS_ChannelBytes2Seconds(stream, pos);

            return((int)posSec);
        }
Exemplo n.º 9
0
        public int GetTimeOfStream(int stream)
        {
            long   Bytes = Bass.BASS_ChannelGetLength(stream);
            double Time  = Bass.BASS_ChannelBytes2Seconds(stream, Bytes);

            return((int)Time);
        }
Exemplo n.º 10
0
        public static void Play(Playlists PlayItem)
        {
            if (Bass.BASS_GetInfo() == null)
            {
                Bass.BASS_Init(-1, hz, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
            }
            Bass.BASS_StreamFree(_stream);
            Bass.BASS_ChannelStop(_stream);

            _stream = Bass.BASS_StreamCreateFile(PlayItem.Path, 0, 0, BASSFlag.BASS_DEFAULT);
            now     = PlayList.IndexOf(PlayItem);
            Bass.BASS_ChannelSetAttribute(_stream, BASSAttribute.BASS_ATTRIB_VOL, slrVolume / 100f);

            EqualizerSettings.SetFX(_stream);

            ggg.Dispatcher.Invoke(() =>
            {
                ggg.lblAudioName.Content = PlayItem.Name;
                ggg.SyncSlider();
                ggg.lblMusicDuration.Content = new TimeSpan(0, 0, (int)Bass.BASS_ChannelBytes2Seconds(BassMet._stream, Bass.BASS_ChannelGetLength(BassMet._stream)));
                ggg.btnResumePause.Content   = "Pause";
            });


            Bass.BASS_ChannelPlay(_stream, true);
            timer.Start();
        }
Exemplo n.º 11
0
        public static int GetPosOfStream(int stream)
        {
            long pos    = Bass.BASS_ChannelGetPosition(stream);
            int  posSec = (int)Bass.BASS_ChannelBytes2Seconds(stream, pos);

            return(posSec);
        }
Exemplo n.º 12
0
        private static int GetStreamPos(int steam)
        {
            long pos    = Bass.BASS_ChannelGetPosition(steam);
            int  posSec = (int)Bass.BASS_ChannelBytes2Seconds(steam, pos);

            return(posSec);
        }
Exemplo n.º 13
0
        private void AddFiles(string[] files)
        {
            TimeSpan startTime = new TimeSpan();

            foreach (string f in files)
            {
                try
                {
                    TagLib.Tag tags           = TagLib.File.Create(f).Tag;
                    int        playingChannel = Bass.BASS_StreamCreateFile(f, 0, 0, 0);
                    TimeSpan   playingLength  = new TimeSpan(0, 0, 0, 0, (int)(Bass.BASS_ChannelBytes2Seconds(playingChannel, Bass.BASS_ChannelGetLength(playingChannel, BASSMode.BASS_POS_BYTE)) * 1000));

                    int uid = UID++;
                    audioFiles.Add(new AudioFile()
                    {
                        UID = uid, Tags = tags, Duration = playingLength, Location = f, StartTime = startTime
                    });
                    startTime += audioFiles.Last().Duration;

                    scrubber.TotalTime += playingLength;

                    fileList.Items.Add(new ListViewItem(new string[] { tags.Track + "", tags.Title == null ? System.IO.Path.GetFileName(f) : tags.Title, playingLength.ToString(@"hh\:mm\:ss"), tags.Album, f })
                    {
                        Name = "" + (uid), Tag = uid
                    });
                }
                catch { }
            }
        }
Exemplo n.º 14
0
        protected static int GetTimeOfStream(int stream)
        {
            long   TimeBytes = Bass.BASS_ChannelGetLength(stream);
            double Time      = Bass.BASS_ChannelBytes2Seconds(stream, TimeBytes);

            return((int)Time);
        }
Exemplo n.º 15
0
        private void updateFrames()
        {
            MessageBox.Show("Ci sono");
            int endFrame = (int)(Math.Floor(Bass.BASS_ChannelBytes2Seconds(streamHandle, Bass.BASS_ChannelGetLength(streamHandle)) / waveForm.FrameResolution));

            while (Bass.BASS_ChannelGetPosition(streamHandle, BASSMode.BASS_POS_BYTES) < Bass.BASS_ChannelGetLength(streamHandle) &&
                   curFrame <= endFrame)
            {
                //MessageBox
                curFrame = (int)(Math.Floor(Bass.BASS_ChannelBytes2Seconds(streamHandle, Bass.BASS_ChannelGetPosition(streamHandle, BASSMode.BASS_POS_BYTES))) / waveForm.FrameResolution);
                if (curFrame > zoom)
                {
                    zoomEnd = curFrame;
                }
                else
                {
                    zoomEnd = zoom;
                }
                zoomStart = zoomEnd - zoom;
                DrawWave();
                Thread.Sleep(500);
            }

            MessageBox.Show("Luke Shaw");
        }
Exemplo n.º 16
0
        private void CheckPosition()
        {
            Int64 MIDILengthRAW     = Bass.BASS_ChannelGetLength(Data.StreamHandle);
            Int64 MIDICurrentPosRAW = Bass.BASS_ChannelGetPosition(Data.StreamHandle);

            RAWTotal     = ((float)MIDILengthRAW) / 1048576f;
            RAWConverted = ((float)MIDICurrentPosRAW) / 1048576f;
            Double LenRAWToDouble = Bass.BASS_ChannelBytes2Seconds(Data.StreamHandle, MIDILengthRAW);
            Double CurRAWToDouble = Bass.BASS_ChannelBytes2Seconds(Data.StreamHandle, MIDICurrentPosRAW);

            Data.TotalTime   = TimeSpan.FromSeconds(LenRAWToDouble);
            Data.CurrentTime = TimeSpan.FromSeconds(CurRAWToDouble);
            Bass.BASS_ChannelGetAttribute(Data.StreamHandle, BASSAttribute.BASS_ATTRIB_MIDI_PPQN, ref Data.PPQN);
            Data.TotalTicks = Convert.ToUInt32(Bass.BASS_ChannelGetLength(Data.StreamHandle, BASSMode.BASS_POS_MIDI_TICK));
            Data.Tick       = Convert.ToUInt32(Bass.BASS_ChannelGetPosition(Data.StreamHandle, BASSMode.BASS_POS_MIDI_TICK));
            Int32 Tempo = 60000000 / BassMidi.BASS_MIDI_StreamGetEvent(Data.StreamHandle, 0, BASSMIDIEvent.MIDI_EVENT_TEMPO);

            Data.Tempo = Convert.ToUInt32(Tempo.LimitIntegerToRange(0, 999));

            try
            {
                Data.Bar               = Convert.ToUInt32(((Int64)(Data.Tick / (Data.PPQN / (8 / 4) * 4))).LimitLongToRange(0, 9223372036854775807));
                Data.TotalBars         = Convert.ToUInt32(((Int64)(Data.TotalTicks / (Data.PPQN / (8 / 4) * 4))).LimitLongToRange(0, 9223372036854775807));
                Data.HowManyZeroesBars = "000";
            }
            catch
            {
                Data.Bar       = 0;
                Data.TotalBars = 0;
            }
        }
Exemplo n.º 17
0
        //получаем длительность трека
        public static int getPosOfChanal(int chanal)
        {
            long posBytes = Bass.BASS_ChannelGetPosition(chanal);
            int  posSec   = (int)Bass.BASS_ChannelBytes2Seconds(chanal, posBytes);

            return(posSec);
        }
Exemplo n.º 18
0
        public static int getTimeOfStream(int stream)//получение длительности в секундах
        {
            long   TimeBytes = Bass.BASS_ChannelGetLength(stream);
            double Time      = Bass.BASS_ChannelBytes2Seconds(stream, TimeBytes);

            return((int)Time);
        }
Exemplo n.º 19
0
 public void GetTags()
 {
     if (Program.mainWindow == null)
     {
         return;
     }
     try
     {
         if (Program.mainWindow.supportedModuleTypes.Contains(Path.GetExtension(filename).ToLower()))
         {
             Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
             int track = Bass.BASS_MusicLoad(filename, 0, 0, BASSFlag.BASS_MUSIC_NOSAMPLE | BASSFlag.BASS_MUSIC_PRESCAN, 0);
             title  = Bass.BASS_ChannelGetMusicName(track);
             artist = Bass.BASS_ChannelGetMusicMessage(track);
             length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track));
             Bass.BASS_Free();
         }
         else if (Program.mainWindow.supportedMidiTypes.Contains(Path.GetExtension(filename).ToLower()))
         {
             Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
             int track = BassMidi.BASS_MIDI_StreamCreateFile(filename, 0, 0, BASSFlag.BASS_DEFAULT, 0);
             title  = Path.GetFileName(filename);
             length = (int)Bass.BASS_ChannelBytes2Seconds(track, (int)Bass.BASS_ChannelGetLength(track));
             Bass.BASS_Free();
         }
         else
         {
             TagLib.File tagFile = TagLib.File.Create(filename);
             title = tagFile.Tag.Title;
             if (tagFile.Tag.Performers.Length > 0)
             {
                 artist = tagFile.Tag.Performers[0];
             }
             album = tagFile.Tag.Album;
             //year = tagFile.Tag.Year+"";
             //comment = tagFile.Tag.Comment;
             length  = (int)tagFile.Properties.Duration.TotalSeconds;
             bitrate = tagFile.Properties.AudioBitrate;
             tagFile.Dispose();
         }
     }
     catch (Exception)
     {
         title  = filename;
         length = 0;
     }
     if (String.IsNullOrWhiteSpace(title))
     {
         title = Path.GetFileName(filename);
     }
     try
     {
         listened = Int32.Parse(Program.mainWindow.xmlCacher.GetListened(filename));
     }
     catch (Exception)
     {
         listened = 0;
     }
 }
Exemplo n.º 20
0
        public void BassTimeLeft(Object sender) //Left time in second label timer
        {
            Controller controller = referenceFromEngien.Target as Controller;
            int        fullTime   = Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream)));
            int        curTime    = Convert.ToInt32(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream)));

            controller.TravelLeftTimerLabel(fullTime - curTime);
        }
Exemplo n.º 21
0
 private void TimerUpd(object sender, EventArgs e)
 {
     Time.Content  = SecondtoMinutes(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream)));
     RTime.Content = "-" + SecondtoMinutes(Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetLength(stream) -
                                                                          Bass.BASS_ChannelGetPosition(stream)));
     TimeS.Value = (double)Bass.BASS_ChannelGetPosition(stream)
                   / (double)Bass.BASS_ChannelGetLength(stream) * 10;
 }
Exemplo n.º 22
0
        public uint getLengthMs()
        {
            double length = 0;

            length  = Bass.BASS_ChannelBytes2Seconds(_channel, Bass.BASS_ChannelGetLength(_channel));
            length *= 1000;
            return((uint)length);
        }
Exemplo n.º 23
0
        public uint getCurrentPosMs()
        {
            double pos = 0;

            pos  = Bass.BASS_ChannelBytes2Seconds(_channel, Bass.BASS_ChannelGetPosition(_channel));
            pos *= 1000;
            return((uint)pos);
        }
Exemplo n.º 24
0
    // milliseconds
    public double GetPositionMS(int _stream)
    {
        long   pos    = Bass.BASS_ChannelGetPosition(_stream);
        double second = Bass.BASS_ChannelBytes2Seconds(_stream, pos);
        double result = second * 1000;

        return(result);
    }
Exemplo n.º 25
0
        private void Timer_Tick(object sender, EventArgs e)
        {
            int min, sec;

            timerBind.Nowtime = (int)Bass.BASS_ChannelBytes2Seconds(stream, Bass.BASS_ChannelGetPosition(stream));
            ConvertMin(out min, out sec, timerBind.Nowtime);
            NowBox.Text = min + ":" + sec;
        }
Exemplo n.º 26
0
        //получаем длительность трека
        public static int GetTimeOfChanal(int chanal)
        {
            long TimeBytes = Bass.BASS_ChannelGetLength(chanal);//получаем длительность в байтах
            //переводим её в секунды
            double Time = Bass.BASS_ChannelBytes2Seconds(chanal, TimeBytes);

            return((int)Time);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Длительность канала в секундах
        /// </summary>
        /// <param name="stream"></param>
        /// <returns></returns>
        public static double GetTimeOfStream(int stream)
        {
            long   TimeBytes = Bass.BASS_ChannelGetLength(stream);
            double Time      = Bass.BASS_ChannelBytes2Seconds(stream, TimeBytes);

            //return (int)Time;
            return(Time);
        }
        //Получение длительности в секундах
        public static int GetSongLenght(int stream)
        {
            long SongLenghtBytes = Bass.BASS_ChannelGetLength(stream);
            //Т.к. длительность мы получаем в байтах
            double SongLenght = Bass.BASS_ChannelBytes2Seconds(stream, SongLenghtBytes);

            return((int)SongLenght);
        }
Exemplo n.º 29
0
        public string GetTimeLineString()
        {
            this._positionInByte = Bass.BASS_ChannelGetPosition(this._stream);
            double seconds  = Bass.BASS_ChannelBytes2Seconds(this._stream, this._positionInByte);
            double seconds2 = Bass.BASS_ChannelBytes2Seconds(this._stream, this._lengthInByte);

            return(string.Format(" {0:#0.00} / {1:#0.00}", Utils.FixTimespan(seconds, "MMSS"), Utils.FixTimespan(seconds2, "MMSS")));
        }
Exemplo n.º 30
0
 /// <summary>
 /// 再生位置を取得する
 /// </summary>
 /// <returns>再生位置(ミリ秒)</returns>
 public uint getPosition()
 {
     {
         long   position = Bass.BASS_ChannelGetPosition(sound[PlayerController.MainChannel]);
         double seconds  = Bass.BASS_ChannelBytes2Seconds(sound[PlayerController.MainChannel], position);
         return((uint)TimeSpan.FromSeconds(seconds).TotalMilliseconds);
     }
 }