public void przygotowanie_odtwarzania() { //czas odtwarzania probki audio_stoper_length = plik_wejsciowy.get_sample_length(current_sample); //================================================================================= // Przygotowanie odtwarzacza //================================================================================= // Player_Setup(Application.StartupPath + "\\" + plik_wejsciowy.get_video_samp(current_sample)); Player_Setup(plik_wejsciowy.get_video_samp(current_sample)); //================================================================================= // odtwarzanie //================================================================================= player.Play(); #region log: poprawne rozpoczecie odtwarzania sampli if (!File.Exists(@"log.txt")) { using (StreamWriter writer = new StreamWriter(@"log.txt", true)) { string tmp = "log file for experiment"; writer.WriteLine(tmp); } } try { using (StreamWriter writer = new StreamWriter(@"log.txt", true)) { string date_time = DateTime.Now.ToString(); string tmp = date_time + " poprawnie rozpoczecie odtarzania sampli: \n\t" + plik_wejsciowy.get_video_samp(current_sample) + "\n\t" + plik_wejsciowy.get_audio_samp(current_sample); writer.WriteLine(tmp); } } catch { } #endregion timer1.Interval = audio_stoper_length; timer1.Enabled = true; }
public void przygotowanie_odtwarzania() { //czas odtwarzania probki audio_stoper_length = plik_wejsciowy.get_sample_length(current_sample); #region jesli ma byc odtwarzany dzwiek try { BassAsio.BASS_ASIO_Stop(); BassAsio.BASS_ASIO_Free(); } catch { } //================================================================================= // Kopiowanie całego strumienia audio do pamięci // //otwarcie pliku audio, pobranie jego wielkosci //wczytanie pliku do buforu //zamkniecie pliku //utworzenie uchwytu, ktory zapobiegnie usunieciu pliku //ustawienie czasu odtwarzania //================================================================================= FileStream fs = File.OpenRead(plik_wejsciowy.get_audio_samp(current_sample)); byte[] temp = new byte[44]; fs.Read(temp, 0, 44); long lf = 44 + BitConverter.ToUInt32(temp, 40); length = lf + BitConverter.ToUInt32(temp, 28); audio_buffer = new byte[length]; for (long i = 0; i < length; i++) { audio_buffer[i] = 0; } fs.Position = 0; fs.Read(audio_buffer, 0, (int)lf); fs.Close(); _hGCFile = GCHandle.Alloc(audio_buffer, GCHandleType.Pinned); //================================================================================= // Przygotowanie całego BASS_Asio //================================================================================= Asio_Setup(urzadzenie); #endregion //================================================================================= // Przygotowanie odtwarzacza //================================================================================= // Player_Setup(Application.StartupPath + "\\" + plik_wejsciowy.get_video_samp(current_sample)); Player_Setup(plik_wejsciowy.get_video_samp(current_sample)); //================================================================================= // odtwarzanie //================================================================================= player.Play(); if (!BassAsio.BASS_ASIO_Start(0)) { // BASSError blad = BassAsio.BASS_ASIO_ErrorGetCode(); // MessageBox.Show("błąd odtwarzania: " + blad.ToString()); } #region log: poprawne rozpoczecie odtwarzania sampli if (!File.Exists(@"log.txt")) { using (StreamWriter writer = new StreamWriter(@"log.txt", true)) { string tmp = "log file for experiment"; writer.WriteLine(tmp); } } try { using (StreamWriter writer = new StreamWriter(@"log.txt", true)) { string date_time = DateTime.Now.ToString(); string tmp = date_time + " poprawnie rozpoczecie odtarzania sampli: \n\t" + plik_wejsciowy.get_video_samp(current_sample) + "\n\t" + plik_wejsciowy.get_audio_samp(current_sample); writer.WriteLine(tmp); } } catch { } #endregion timer1.Interval = audio_stoper_length; timer1.Enabled = true; }