/// <summary> /// Modifies the ISO to make the next batch available to the recorder /// </summary> /// <param name="refVoiceIdToReplace">The real voice id of the first line of the scene</param> /// <param name="startIdOfNextBatch">Will replace the ref with this one, plus next 5 IDs (incremental)</param> /// <param name="numberOfVoices">The number of voices to replace</param> public static void PrepareNextBatch(int refVoiceIdToReplace, int startIdOfNextBatch, int numberOfVoices) { if (string.IsNullOrWhiteSpace(isoFilePath) || File.Exists(isoFilePath) == false) { throw new InvalidOperationException("Fichier ISO introuvable ou chemin non renseigné"); } LazyLoadCache(); List <Tuple <long, int> > positionsToWriteToAndModifiedValues = new List <Tuple <long, int> >(); for (int i = 0; i < numberOfVoices; i++) { int voiceIdToSeek = SoundInfo.GetVoiceIdAtOffsetFromVoiceId(refVoiceIdToReplace, i); int voiceIdToPut = SoundInfo.GetVoiceIdAtOffsetFromVoiceId(startIdOfNextBatch, i); if (voiceIDsPositionsAndValueCache.Any(x => x.Item2 == voiceIdToSeek)) { long positionInFile = voiceIDsPositionsAndValueCache.Where(x => x.Item2 == voiceIdToSeek).FirstOrDefault().Item1; if (positionInFile != 0 && voiceIdToPut != 0) { positionsToWriteToAndModifiedValues.Add(new Tuple <long, int>( positionInFile, voiceIdToPut)); } } } var binWriter = new BinaryWriter(File.OpenWrite(isoFilePath), Encoding.ASCII); binWriter.BaseStream.Position = startAddress; using (binWriter) { foreach (var positionAndModifiedValue in positionsToWriteToAndModifiedValues) { binWriter.BaseStream.Position = positionAndModifiedValue.Item1; binWriter.Write(ASCIIEncoding.ASCII.GetBytes(positionAndModifiedValue.Item2.ToString())); } binWriter.Flush(); } }
string GetTempFileName(int currentBatchStartId, int numberOfVoicesAvailable) { string tempFileName = Path.Combine(fmediaWorkDir, string.Format("{0}_{1}.wav", currentBatchStartId, SoundInfo.GetVoiceIdAtOffsetFromVoiceId(currentBatchStartId, numberOfVoicesAvailable))); if (File.Exists(tempFileName)) { File.Delete(tempFileName); } return(tempFileName); }