private void RefreshMarkers(int x) { markers.Add(x); markers.Sort(); m_parent.outputFiles.RemoveAllSoundFiles(); m_parent.dataGridView1.Rows.Clear(); m_parent.Refresh(); var soundFile = new SoundFile(); m_parent.addSoundFile(soundFile); for (int i = 0; i < markers.Count; i++) { soundFile = new SoundFile { fileName = $"File_{i}", startTimeSeconds = (i == 0) ? 0 : PointToTime(markers[i - 1]), endTimeSeconds = PointToTime(markers[i]) }; m_parent.addSoundFile(soundFile); } soundFile = new SoundFile { fileName = $"File_{markers.Count}", startTimeSeconds = PointToTime(markers[markers.Count - 1]), endTimeSeconds = PointToTime(m_volumeSamples.Count) }; m_parent.addSoundFile(soundFile); }
public void AddSoundFile(SoundFile sound) { if (sound.tag == null) { sound.AddTagInfo(m_inputFileTags); } m_outputFiles.Add(index, sound); }
public TAG_INFO FillInputFileTags(string inputFileText) { m_inputFileTags = BassTags.BASS_TAG_GetFromFile(inputFileText); if (m_outputFiles == null) { var sound = new SoundFile(tag: m_inputFileTags); m_outputFiles = new OutputFiles(sound); } return(m_inputFileTags); }
public void addSoundFile(SoundFile sound) { outputFiles.AddSoundFile(sound); AddRowToDataGridView(sound); UpdateDGVRowNumbers(); if (outputFiles.CountOfSoundFiles > 1) { deleteButton.Enabled = true; } LeftAndRightButtonsEnableDisable(); UpdateEditingPosition(); }
public void AddRowToDataGridView(SoundFile sound) { int index = 0; if (dataGridView1.Rows.Count == 0) { dataGridView1.Rows.Add(); } else { index = outputFiles.GetCurrentFileIndex(); dataGridView1.Rows.Insert(index); } dataGridView1.Rows[index].Cells[1].Value = sound.fileName; dataGridView1.Rows[index].Cells[2].Value = sound.startTimeSeconds; dataGridView1.Rows[index].Cells[3].Value = sound.endTimeSeconds; }
/// <summary> /// Finds sections of silence in a sound stream. /// </summary> /// <param name="file">Filename for the sound stream.</param> /// <param name="block">The block of time of a sample to get the level (peak amplitude), default is 20 miliseconds.</param> /// <param name="silence">The silence time to split by default is 2000 miliseconds (2 seconds).</param> /// <param name="minGap">The minimum time for the splits, default is 480000 miliseconds (8 mins).</param> /// <param name="bgWorker">The BackgroundWorker to report progress.</param> /// <returns>List of sound files</returns> public static List <SoundFile> FindSilence(string file, float block = 20, float silence = 2000, float minGap = 480000, BackgroundWorker bgWorker = null) { int level = 0; int count = 0; float gap = 0; float start = 0; float position = block; var buffer = new IntPtr(); var sounds = new List <SoundFile>(); var volumeStream = new List <int>(); var chan = Bass.BASS_StreamCreateFile(file, 0, 0, BASSFlag.BASS_STREAM_DECODE); var len = Bass.BASS_ChannelSeconds2Bytes(chan, block / (float)1000 - (float)0.02); while ((level = Bass.BASS_ChannelGetLevel(chan)) != -1) { int left = Utils.LowWord32(level); int right = Utils.HighWord32(level); volumeStream.Add(left + right); if (((count = ((left + right) < 40000) ? count + 1 : 0) == silence / block) && (gap > minGap)) { var pos = (int)Math.Round(position / 1000); var sound = new SoundFile($"File_{pos}", start / 1000.0, position / 1000.0); bgWorker?.ReportProgress(pos, sound); start = position + 1; sounds.Add(sound); gap = 0; } else if (position % 50000 == 0) { bgWorker?.ReportProgress((int)Math.Round(position / 1000), volumeStream); } Bass.BASS_ChannelGetData(chan, buffer, (int)len); position += block; gap += block; } Bass.BASS_StreamFree(chan); return(sounds); }