Esempio n. 1
0
        private void buttonAddFile_Click(object sender, EventArgs e)
        {
            if (DialogResult.OK == openFileDialog.ShowDialog(this))
            {
                if (File.Exists(openFileDialog.FileName))
                {
                    lock (listBoxPlaylist)
                    {
                        Track track = new Track(openFileDialog.FileName);
                        listBoxPlaylist.Items.Add(track);

                        // in the demo we already add each new track to the mixer
                        // this is in real life not the best place to do so (especially with larger playlists)
                        // but for the demo it is okay ;-)

                        // add the new track to the mixer (in PAUSED mode!)
                        BassMix.BASS_Mixer_StreamAddChannel(_mixer, track.Channel, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);

                        // an BASS_SYNC_END is used to trigger the next track in the playlist (if no POS sync was set)
                        track.TrackSync = new SYNCPROC(OnTrackSync);
                        BassMix.BASS_Mixer_ChannelSetSync(track.Channel, BASSSync.BASS_SYNC_END, 0L, track.TrackSync, new IntPtr(0));
                    }

                    if (_currentTrack == null)
                    {
                        PlayNextTrack();
                    }
                }
            }
        }
Esempio n. 2
0
        private void MyWaveFormCallback(int framesDone, int framesTotal, TimeSpan elapsedTime, bool finished)
        {
            if (finished)
            {
                _WF.SyncPlayback(_currentTrack.Channel);

                // and do pre-calculate the next track position
                // in this example we will only use the end-position
                long startPos = 0L;
                long endPos   = 0L;
                if (_WF.GetCuePoints(ref startPos, ref endPos, -24.0, -12.0, true))
                {
                    _currentTrack.NextTrackPos = endPos;
                    // if there is already a sync set, remove it first
                    if (_currentTrack.NextTrackSync != 0)
                    {
                        BassMix.BASS_Mixer_ChannelRemoveSync(_currentTrack.Channel, _currentTrack.NextTrackSync);
                    }

                    // set the next track sync automatically
                    _currentTrack.NextTrackSync = BassMix.BASS_Mixer_ChannelSetSync(_currentTrack.Channel, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, _currentTrack.NextTrackPos, _currentTrack.TrackSync, new IntPtr(1));

                    _WF.AddMarker("Next", _currentTrack.NextTrackPos);
                }
            }
            // will be called during rendering...
            DrawWave();
        }
Esempio n. 3
0
        public void StreamAddChannel(int channel, SYNCPROC trackSync)
        {
            //BassMix.BASS_Mixer_StreamAddChannel(Player.Mixer, channel, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_STREAM_AUTOFREE | BASSFlag.BASS_MIXER_DOWNMIX);
            BassMix.BASS_Mixer_StreamAddChannel(Player.Mixer, channel, BASSFlag.BASS_MIXER_PAUSE | BASSFlag.BASS_MIXER_DOWNMIX | BASSFlag.BASS_STREAM_AUTOFREE);

            // an BASS_SYNC_END is used to trigger the next track in the playlist (if no POS sync was set)
            BassMix.BASS_Mixer_ChannelSetSync(channel, BASSSync.BASS_SYNC_END, 0L, trackSync, new IntPtr(1));
        }
        private static void AddSyncToStream(AudioStream audioStream, AudioSync audioSync)
        {
            lock (audioStream)
            {
                audioStream.AudioSyncs.Add(audioSync);
            }

            if (audioSync.SyncType == SyncType.Start || audioStream.DisableSyncs)
            {
                return;
            }

            audioSync.Id = BassMix.BASS_Mixer_ChannelSetSync(audioStream.ChannelId,
                                                             BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME,
                                                             audioSync.Position,
                                                             audioStream.SyncProc,
                                                             new IntPtr((int)audioSync.SyncType));
        }
Esempio n. 5
0
        public void Play_With_Buildup()
        {
            Stop();
            if (InitBass(HZ))
            {
                Channel = BassMix.BASS_Mixer_StreamCreate(HZ, 2, BASSFlag.BASS_MIXER_END);

                point_B = GCHandle.Alloc(build_mem, GCHandleType.Pinned);
                point_L = GCHandle.Alloc(loop_mem, GCHandleType.Pinned);

                Stream_B  = Bass.BASS_StreamCreateFile(point_B.AddrOfPinnedObject(), 0, build_mem.LongLength, BASSFlag.BASS_STREAM_DECODE);
                build_len = Bass.BASS_ChannelGetLength(Stream_B, BASSMode.BASS_POS_BYTES);

                Stream_L = Bass.BASS_StreamCreateFile(point_L.AddrOfPinnedObject(), 0, loop_mem.LongLength, BASSFlag.BASS_STREAM_DECODE);
                loop_len = Bass.BASS_ChannelGetLength(Stream_L);

                BassMix.BASS_Mixer_StreamAddChannel(Channel, Stream_B, BASSFlag.BASS_DEFAULT);
                BassMix.BASS_Mixer_StreamAddChannelEx(Channel, Stream_L, BASSFlag.BASS_MIXER_NORAMPIN, build_len, 0);

                _loopSync = BassMix.BASS_Mixer_ChannelSetSync(Stream_L, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, loop_len, _loopSyncCallback, new IntPtr(1));
            }
        }
Esempio n. 6
0
        private void pictureBoxWaveForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            if (_WF == null)
            {
                return;
            }

            bool doubleClick = e.Clicks > 1;
            bool lowerHalf   = (e.Y > pictureBoxWaveForm.Height / 2);

            if (lowerHalf && doubleClick)
            {
                ToggleZoom();
            }
            else if (!lowerHalf && e.Button == MouseButtons.Left)
            {
                // left button will set the position
                long pos = _WF.GetBytePositionFromX(e.X, pictureBoxWaveForm.Width, _zoomStart, _zoomEnd);
                SetEnvelopePos(_currentTrack.Channel, pos);
            }
            else if (!lowerHalf)
            {
                _currentTrack.NextTrackPos = _WF.GetBytePositionFromX(e.X, pictureBoxWaveForm.Width, _zoomStart, _zoomEnd);
                // if there is already a sync set, remove it first
                if (_currentTrack.NextTrackSync != 0)
                {
                    BassMix.BASS_Mixer_ChannelRemoveSync(_currentTrack.Channel, _currentTrack.NextTrackSync);
                }

                // right button will set a next track position sync
                _currentTrack.NextTrackSync = BassMix.BASS_Mixer_ChannelSetSync(_currentTrack.Channel, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, _currentTrack.NextTrackPos, _currentTrack.TrackSync, new IntPtr(1));

                _WF.AddMarker("Next", _currentTrack.NextTrackPos);
                DrawWave();
            }
        }