public static void Execute(string aFilePathOutput, LoopInformation aLoopInformation) { RiffWaveRiff lRiffWaveRiff = ( RiffWaveRiff )PoolCollection.GetRiffWave(aFilePathOutput); WaveformReaderPcm waveform = new WaveformReaderPcm(lRiffWaveRiff, true); OverrideCuePoint(lRiffWaveRiff, ( int )aLoopInformation.start.sample, ( int )aLoopInformation.end.sample); OverrideSampleLoop(lRiffWaveRiff, ( int )aLoopInformation.start.sample, ( int )aLoopInformation.end.sample); Byte[] lDataArrayRead = null; RiffWaveData dataChunk = ( RiffWaveData )lRiffWaveRiff.GetChunk(RiffWaveData.ID); using (FileStream u = new FileStream(lRiffWaveRiff.name, FileMode.Open, FileAccess.Read)) { AByteArray l = new ByteArrayLittle(u); int bytePosition = ( int )dataChunk.position; l.SetPosition(bytePosition); lDataArrayRead = l.ReadBytes(dataChunk.Size); } Byte[] lDataArrayWrite = lDataArrayRead; if (IsCutLast == true) { int lLength = ( int )(aLoopInformation.end.sample + 1) * waveform.format.channels * (waveform.format.sampleBits / 8); Logger.BreakDebug("End:" + aLoopInformation.end.sample); lDataArrayWrite = new Byte[lLength]; for (int i = 0; i < lLength; i++) { lDataArrayWrite[i] = lDataArrayRead[i]; } } SetDataArray(lRiffWaveRiff, lDataArrayWrite); MemoryStream lMemoryStreamWrite = new MemoryStream(( int )lRiffWaveRiff.Size + 8); ByteArrayLittle lByteArray = new ByteArrayLittle(lMemoryStreamWrite); lRiffWaveRiff.WriteByteArray(lByteArray); Logger.BreakDebug("WriteByteArray"); Logger.BreakDebug("Out:" + aFilePathOutput); try { using (FileStream u = new FileStream(aFilePathOutput, FileMode.Create, FileAccess.Write, FileShare.Read)) { u.Write(lMemoryStreamWrite.GetBuffer(), 0, ( int )lMemoryStreamWrite.Length); } } catch (Exception aExpection) { Logger.BreakError("Write Exception:" + aExpection); } }
public SoundfontSfz(SfzRegion sfzData) { byte lokey = sfzData.lokey; byte hikey = sfzData.hikey; bool loopMode = sfzData.loop_mode; int loopStart = sfzData.loop_start - 1; int loopEnd = sfzData.loop_end; int offset = sfzData.offset; int end = sfzData.end; int tune = sfzData.tune; int pitchKeyCenter = sfzData.pitch_keycenter; float volume = sfzData.volume; soundinfo = new Soundinfo(lokey, hikey, loopMode, loopStart, loopEnd, offset, end, tune, pitchKeyCenter, 0, 0, volume); ampeg = new Ampeg(sfzData.ampeg_delay, sfzData.ampeg_start / 100.0f, sfzData.ampeg_attack, sfzData.ampeg_hold, sfzData.ampeg_decay, sfzData.ampeg_sustain / 100.0f, sfzData.ampeg_release); waveform = new WaveformReaderPcm(PoolCollection.GetRiffWave(sfzData.sample), true); }
public MusicWave(string aPathFile) : base(PoolCollection.GetRiffWave(aPathFile)) { }
public static void Execute( string aFilePathInput, string aFilePathOutput, InputMusicInformation aData ) { RiffWaveRiff lRiffWaveRiff = ( RiffWaveRiff )PoolCollection.GetRiffWave( aFilePathInput ); WaveformPcm lWaveform = new WaveformPcm( lRiffWaveRiff ); SByte[] lSampleArray = new SByte[lWaveform.format.samples]; lSampleArray = lWaveform.data.sampleByteArray[0]; List<LoopInformation> lLoopList = null; try { if( lWaveform.format.samples > 44100 * 16 ) { lLoopList = LoopSearchTool.Execute( lSampleArray, aData, aFilePathInput ); } else { lLoopList = LoopSearchToolSoundfont.Execute( lSampleArray, aData, aFilePathInput ); } } catch( Exception aExpection ) { Logger.BreakError( aExpection.ToString() + ":LoopTool Exception" ); } for( int i = 0; i < lLoopList.Count; i++ ) { AddCuePoint( lRiffWaveRiff, ( int )lLoopList[i].start.sample, ( int )lLoopList[i].end.sample ); AddSampleLoop( lRiffWaveRiff, ( int )lLoopList[i].start.sample, ( int )lLoopList[i].end.sample ); } Byte[] lDataArrayRead = null; RiffWaveData dataChunk = ( RiffWaveData )lRiffWaveRiff.GetChunk( RiffWaveData.ID ); using ( FileStream u = new FileStream( lRiffWaveRiff.name, FileMode.Open, FileAccess.Read ) ) { AByteArray l = new ByteArrayLittle( u ); int bytePosition = ( int )dataChunk.position; l.SetPosition( bytePosition ); lDataArrayRead = l.ReadBytes( dataChunk.Size ); } SetDataArray( lRiffWaveRiff, lDataArrayRead ); Logger.BreakDebug( "lMemoryStreamWrite" ); MemoryStream lMemoryStreamWrite = new MemoryStream( ( int )lRiffWaveRiff.Size + 8 ); ByteArrayLittle lByteArray = new ByteArrayLittle( lMemoryStreamWrite ); lRiffWaveRiff.WriteByteArray( lByteArray ); Logger.BreakDebug( "WriteByteArray" ); Logger.BreakDebug( "Out:" + aFilePathOutput ); try { using( FileStream u = new FileStream( aFilePathOutput, FileMode.Create, FileAccess.Write, FileShare.Read ) ) { u.Write( lMemoryStreamWrite.GetBuffer(), 0, ( int )lMemoryStreamWrite.Length ); } } catch( Exception aExpection ) { Logger.BreakError( "Write Exception:" + aExpection ); } }