private void backgroundWorker4_DoWork(object sender, DoWorkEventArgs e) { while (bgw4_done < aantal_liedjes) { if (bgw3_done > 0) { if (bgw3_done > bgw4_done || bgw3_done == aantal_liedjes) { if (bgw4_done == 0) { System.IO.File.Copy(File.defaultDir + "\\faded\\" + (bgw4_done + 1) + ".wav", File.defaultDir + "\\total\\total.wav", true); bgw4_done += 1; } else { if (System.IO.File.Exists(File.defaultDir + "\\faded\\" + (bgw4_done + 1).ToString() + ".wav")) { //MusicEditor.MixMp3(File.defaultDir + "\\total\\total.mp3", File.defaultDir + "\\faded\\" + (bgw4_done + 1) + ".mp3", (liedjes[bgw4_done - 1].FadeOut - new DateTime(2000, 1, 1)).TotalSeconds, File.defaultDir + "\\total\\total2.mp3"); WaveFile wf1 = new WaveFile(); wf1.LoadWave(File.defaultDir + "\\total\\total.wav"); WaveFile wf2 = new WaveFile(); wf2.LoadWave(File.defaultDir + "\\faded\\" + (bgw4_done + 1) + ".wav"); WaveFile.StoreMixWave(File.defaultDir + "\\total\\total2.wav", wf1, wf2, (liedjes[bgw4_done - 1].FadeOut - new DateTime(2000, 1, 1)).TotalSeconds); System.IO.File.Delete(File.defaultDir + "\\total\\total.wav"); System.IO.File.Copy(File.defaultDir + "\\total\\total2.wav", File.defaultDir + "\\total\\total.wav"); System.IO.File.Delete(File.defaultDir + "\\total\\total2.wav"); bgw4_done += 1; } else { bgw4_done += 1; } } backgroundWorker4.ReportProgress(1); } } } }