public void OnDivideWav(DivisionInfo divisionInfo) { var wavPositions = divisionInfo.GetPositions(); var itemsGroupedWithBelongedWavIndex = items.GroupBy(item => { var nextWavPosition = wavPositions.FirstOrDefault(x => x > item.StartMs); if (nextWavPosition == 0.0) { return(wavPositions.Count - 1); } var nextWavIndex = wavPositions.IndexOf(nextWavPosition); return(nextWavIndex - 1); }); items = itemsGroupedWithBelongedWavIndex.SelectMany(group => { var belongedWavIndex = group.Key; var items = group.ToList(); return(items.Select(item => { var newWaveFileName = divisionInfo.Items[belongedWavIndex].FileName; var newStartMs = item.StartMs - wavPositions[belongedWavIndex]; return item.Copy(newWaveFileName, newStartMs); })); }).ToList(); }
public void OnRestoreDividedWav(string longWavFileName, DivisionInfo divisionInfo) { var wavPositions = divisionInfo.GetPositions(); items = items.Select(item => { var infoItem = divisionInfo.Items.First(x => x.FileName == item.WavFileName); var position = wavPositions[divisionInfo.Items.IndexOf(infoItem)]; var newStartMs = item.StartMs + position; return(item.Copy(longWavFileName, newStartMs)); }).ToList(); }