Beispiel #1
0
        //void ChkWavestMouseWheel(object sender, MouseEventArgs e)
        //{
        //System.Diagnostics.Debug.WriteLine(chkWaves.TopIndex);
        //System.Diagnostics.Debug.WriteLine(chkWaves.);
        //	Text1MouseWheel(this.textBox1, e);
        //}

        //void Text1MouseWheel(object sender, MouseEventArgs e)
        //{
        //	int pos = textBox1.GetCharIndexFromPosition(e.Location);
        //	int line = textBox1.GetLineFromCharIndex(pos);
        //	System.Diagnostics.Debug.WriteLine(line);
        //}

        void ChkWavesSelectedIndexChanged(object sender, EventArgs e)
        {
            if (chkWaves.SelectedIndex == -1)
            {
                return;
            }
            gPlayer.StopPlayback();
            gPlayer.Close();

            String selFile = chkWaves.SelectedItem.ToString();

            String folder = cmbQisquchlar.SelectedItem.ToString();
            string yol    = Path.Combine(gAwazyol, folder, selFile);

            gInfo = new TStreamInfo();
            gPlayer.OpenFile(yol, TStreamFormat.sfAutodetect);
            gPlayer.GetStreamInfo(ref gInfo);
            label2.Text = string.Format("Uzunluqi : {0} millisecond", gInfo.Length.ms);

            int qur = chkWaves.SelectedIndex;

            textBox1.Focus();
            int qurUzun = 0;

            if (qur < textBox1.Lines.Length)
            {
                qurUzun = textBox1.GetFirstCharIndexFromLine(qur);
            }
            textBox1.SelectionLength = 0;
            textBox1.SelectionStart  = qurUzun;
            textBox1.ScrollToCaret();
        }
Beispiel #2
0
        private void _loadImformation(string filename)
        {
            IsEmpty = true;
            if (filename == string.Empty)
            {
                return;
            }
            FilePath = filename;
            #region 获取文件信息
            #region 设置文件时间
            ZPlay tempPlay = new ZPlay();
            //如果文件不存在,则退出构造..
            bool bret = tempPlay.OpenFile(filename, TStreamFormat.sfAutodetect);
            if (!bret)
            {
                return;
            }
            TStreamInfo streamInfo = new TStreamInfo();
            tempPlay.GetStreamInfo(ref streamInfo);
            Length  = streamInfo.Length;
            Minutes = streamInfo.Length.sec / 60;
            Seconds = streamInfo.Length.sec % 60;

            tempPlay.Close();
            #endregion
            #region 获取歌曲名
            string musicName = filename.Substring(filename.LastIndexOf('\\') + 1);
            MusicName = musicName.Substring(0, musicName.LastIndexOf('.'));
            #endregion
            #region 设置文件格式
            string format = filename.Substring(filename.LastIndexOf('.'));
            switch (format.ToLower())
            {
            case ".wav":
                Format = TStreamFormat.sfWav;
                break;

            case ".mp3":
                Format = TStreamFormat.sfMp3;
                break;

            case ".flac":
                Format = TStreamFormat.sfFLAC;
                break;

            default:
                Format = TStreamFormat.sfAutodetect;
                break;
            }
            #endregion
            IsEmpty = false;

            #endregion
        }
Beispiel #3
0
        public void StartLibZPlay()
        {
            _stopPlayer = false;

            // open file
            var fileName =
                "wavein://src=microphone;volume=50;";
            // @"C:\Users\david_000\Music\my best remixes\10 vibromatic.mp3";

            FixedSizedQueue <FFTData> fftDatas = new FixedSizedQueue <FFTData>();

            fftDatas.Limit = 5000;

            if (!_player.OpenFile(fileName, TStreamFormat.sfAutodetect))
            {
                return;
            }
            _player.StartPlayback();
            Pause();
            while (_continue && !_stopPlayer)
            {
                FFTData fftData = new FFTData();
                _player.GetFFTData(512, TFFTWindow.fwRectangular, ref fftData.HarmonicNumber, ref fftData.HarmonicFreq, ref fftData.LeftAmplitude, ref fftData.RightAmplitude, ref fftData.LeftPhase, ref fftData.RightPhase);
                fftDatas.Enqueue(fftData);
                if (change(fftDatas))
                {
                    _display = true;
                }

                System.Threading.Thread.Sleep(1);
            }

            _player.Close();

            if (_continue)
            {
                StartLibZPlay();
            }
        }
Beispiel #4
0
		private void OpenFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)
		{

			
            
			TStreamFormat format = player.GetFileFormat(OpenFileDialog1.FileName);
   
			if (LoadMode == 0)
			{
                player.Close();
				if (! (player.OpenFile(OpenFileDialog1.FileName, TStreamFormat.sfAutodetect )))
				{
					MessageBox.Show(player.GetError(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
				}
			}
			else if (LoadMode == 1)
			{
                player.Close();
				System.IO.FileInfo fInfo = new System.IO.FileInfo(OpenFileDialog1.FileName);
				long numBytes = fInfo.Length;
				System.IO.FileStream fStream = new System.IO.FileStream(OpenFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
				System.IO.BinaryReader br = new System.IO.BinaryReader(fStream);
				byte[] stream_data = null;

				stream_data = br.ReadBytes(System.Convert.ToInt32((int)(numBytes)));
                if (!(player.OpenStream(true, false, ref stream_data, System.Convert.ToUInt32(numBytes), format)))
				{
					MessageBox.Show(player.GetError(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}

				br.Close();
				fStream.Close();
			}
			else if (LoadMode == 2)
			{
                player.Close();
				BufferCounter = 0;

				System.IO.FileInfo fInfo = new System.IO.FileInfo(OpenFileDialog1.FileName);
				uint numBytes = System.Convert.ToUInt32(fInfo.Length);
				if (br != null)
				{
					br.Close();
				}
				if (fStream != null)
				{
					fStream.Close();
				}

				br = null;
				fStream = null;

				fStream = new System.IO.FileStream(OpenFileDialog1.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
				br = new System.IO.BinaryReader(fStream);
				byte[] stream_data = null;
				uint small_chunk = 0;
				small_chunk = System.Convert.ToUInt32(Math.Min(100000, numBytes));
				// read small chunk of data
				stream_data = br.ReadBytes(System.Convert.ToInt32((int)(small_chunk)));
				// open stream
				if (! (player.OpenStream(true, true, ref stream_data, System.Convert.ToUInt32(stream_data.Length), format)))
				{
					MessageBox.Show(player.GetError(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
				}

				// read more data and push into stream
				stream_data = br.ReadBytes(System.Convert.ToInt32((int)(small_chunk)));
				player.PushDataToStream(ref stream_data, System.Convert.ToUInt32(stream_data.Length));
			}
            else if (LoadMode == 3)
            {
                if (!(player.AddFile(OpenFileDialog1.FileName, TStreamFormat.sfAutodetect)))
                {
                    MessageBox.Show(player.GetError(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }


            }

			showinfo();
            player.StartPlayback();

		}
Beispiel #5
0
		private void Form1_Load(object sender, System.EventArgs e)
		{
			player = new ZPlay();
			ReverseMode = false;
			Echo = false;

			int left = 0;
			int right = 0;
			player.GetMasterVolume(ref left, ref right);
			leftmastervolume.Value = 100 - left;
			rightmastervolume.Value = 100 - right;
			player.GetPlayerVolume(ref left, ref right);
			leftplayervolume.Value = 100 - left;
			rightplayervolume.Value = 100 - right;

			// callback
			CallbackFunc = new TCallbackFunc(MyCallbackFunc);
            player.SetCallbackFunc(CallbackFunc, (TCallbackMessage)((TCallbackMessage.MsgEnterVolumeSlideAsync | TCallbackMessage.MsgExitVolumeSlideAsync | TCallbackMessage.MsgStreamBufferDoneAsync | TCallbackMessage.MsgNextSongAsync )), 0);

         
			// echo

            
			TEchoEffect[] effect = new TEchoEffect[2];

			effect[0].nLeftDelay = 500;
			effect[0].nLeftSrcVolume = 50;
			effect[0].nLeftEchoVolume = 30;
			effect[0].nRightDelay = 500;
			effect[0].nRightSrcVolume = 50;
			effect[0].nRightEchoVolume = 30;

			effect[1].nLeftDelay = 30;
			effect[1].nLeftSrcVolume = 50;
			effect[1].nLeftEchoVolume = 30;
			effect[1].nRightDelay = 30;
			effect[1].nRightSrcVolume = 50;
			effect[1].nRightEchoVolume = 30;

            player.SetEchoParam(ref effect, 2);
  
            
            /*
            TEchoEffect[] test1 = new TEchoEffect[2];
            int n = player.GetEchoParam(ref test1);
            int i;
            for (i = 0; i < n; i++)
            {
                MessageBox.Show(test1[i].nLeftDelay.ToString());
            }
            */

            /*
            int[] EqPoints = new int[9] { 100, 200, 300, 1000, 2000, 3000, 5000, 7000, 12000 };
            player.SetEqualizerPoints(ref EqPoints, 9);
            */

            /*
            int[] testeq = new int[1];
            int num = player.GetEqualizerPoints(ref testeq);
            int i1;
            for (i1 = 0; i1 < num; i1++)
            {
                MessageBox.Show(testeq[i1].ToString ());

            }
             */
            

            /*
            TWaveOutInfo WaveOutInfo = new TWaveOutInfo();
            int WaveOutNum = player.EnumerateWaveOut();
            uint i;
            for (i = 0; i < WaveOutNum; i++)
            {
                if (player.GetWaveOutInfo(i, ref WaveOutInfo))
                {
                    MessageBox.Show(WaveOutInfo.ProductName );

                }
            }
            
            */


			ComboBox1.SelectedIndex = 0;
			ComboBox2.SelectedIndex = 7;
			ComboBox3.SelectedIndex = 11;

            ComboBox4.SelectedIndex = 0;
            ComboBox5.SelectedIndex = 0;

			if (My.MyApplication.Application.CommandLineArgs.Count != 0)
			{

				player.Close();

				if (LoadMode == 0)
				{
                    if (!(player.OpenFile(My.MyApplication.Application.CommandLineArgs[0], TStreamFormat.sfAutodetect)))
					{
						MessageBox.Show(player.GetError(), string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error);
					}
				}

				showinfo();
                player.StartPlayback();
			}

		}
Beispiel #6
0
 private void SoundPlayer_FormClosing(object sender, FormClosingEventArgs e)
 {
     player.StopPlayback();
     player.Close();
 }
Beispiel #7
0
        public void Run()
        {
            zPlayBuffer   = new CircularBlockBuffer();
            zPlay         = new ZPlay();
            netConnection = new NetConnection();
            netConnection.OnDisconnect += new NC_OnDisconnect(OnDisconnect);
            netConnection.OnTick       += new NC_OnTick(NC_OnTick);
            try
            {
                int result = -1;
                // This is to connect to default vod app
                netConnection.Connect(new ServerLink("rtmp://localhost:1935/vod"), new NC_ResultCallBackConnect((sender, success) =>
                {
                    // Runs in RTMP thread (NOT MainThread!!!)
                    Console.WriteLine("NetConnection.Connect => Success=" + success.ToString());

                    if (success)
                    {
                        result = 1;
                    }
                    else
                    {
                        result = 0;
                    }
                }));

                // Wait until we are connected (needed because we run async)
                while (result == -1)
                {
                    Thread.Sleep(100);
                } //while


                // Succes for connecting to rtmp server
                if (result == 1)
                {
                    NetStream netStream = new NetStream(netConnection);
                    netStream.OnStatus      += new NS_OnStatus(NS_OnStatus);
                    netStream.OnAudioPacket += new NC_OnMediaPacket(NC_OnMediaPacket);

                    netStream.WaitForValidStream_ID(4000); // wait max 4 seconds for the netstream to become valid (for real test connect to event)

                    // This is to get and MP3 stream
                    netStream.Play("Comfort_Fit_-_03_-_Sorry.mp3", 0, -1, true);
                }


                Console.WriteLine("Press enter to stop.");
                Console.ReadLine();
            }
            finally
            {
                // Cleanup
                if (netConnection != null)
                {
                    netConnection.Close();
                    netConnection = null;
                }
                if (zPlay != null)
                {
                    TStreamStatus status = new TStreamStatus();
                    zPlay.GetStatus(ref status);
                    if (status.fPlay)
                    {
                        zPlay.StopPlayback();
                    }

                    zPlay.Close();
                    zPlay = null;
                }
                if (zPlayBuffer != null)
                {
                    zPlayBuffer = null;
                }
            }
        }