public void Init(string fileName, Action <OPNAData> opnaWrite) { pathWork = Path.GetDirectoryName(fileName); fnMUB = fileName; byte[] srcBuf = File.ReadAllBytes(fnMUB); header = new MUBHeader(srcBuf); work.data = GetDATA(); tags = GetTags(); GetFileNameFromTag(); work.fmVoice = GetFMVoiceFromFile(); pcm = GetPCMFromSrcBuf(); if (pcm == null) { GetPCMDataFromFile(); } work.pcmTables = GetPCMTable(); WriteOPNA = opnaWrite; if (pcm != null) { OPNAData[] pcmSendData = GetPCMSendData(); foreach (OPNAData dat in pcmSendData) { WriteRegister(dat); } } music2 = new Music2(work, WriteRegister); }
public void Init(Action <ChipDatum> chipWriteRegister, Action <long, int> chipWaitSend, MmlDatum[] srcBuf, object addtionalOption, Func <string, Stream> appendFileReaderCallback) { if (srcBuf == null || srcBuf.Length < 1) { return; } bool notSoundBoard2 = (bool)((object[])addtionalOption)[0]; bool isLoadADPCM = (bool)((object[])addtionalOption)[1]; bool loadADPCMOnly = (bool)((object[])addtionalOption)[2]; header = new MUBHeader(srcBuf, enc); work.mData = GetDATA(); tags = GetTags(); GetFileNameFromTag(); work.fmVoice = GetFMVoiceFromFile(appendFileReaderCallback); pcm = GetPCMFromSrcBuf() ?? GetPCMDataFromFile(appendFileReaderCallback); work.pcmTables = GetPCMTable(); work.isDotNET = IsDotNETFromTAG(); WriteOPNA = chipWriteRegister; WaitSendOPNA = chipWaitSend; //PCMを送信する if (pcm != null) { if (isLoadADPCM) { ChipDatum[] pcmSendData = GetPCMSendData(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); foreach (ChipDatum dat in pcmSendData) { WriteRegister(dat); } sw.Stop(); WaitSendOPNA(sw.ElapsedMilliseconds, pcmSendData.Length); } } if (loadADPCMOnly) { return; } music2 = new Music2(work, WriteRegister); music2.notSoundBoard2 = notSoundBoard2; }
public void Init(string fileName, Action <OPNAData> opnaWrite, Action <long, int> opnaWaitSend, bool notSoundBoard2, MubDat[] srcBuf, bool isLoadADPCM, bool loadADPCMOnly) { pathWork = Path.GetDirectoryName(fileName); fnMUB = fileName; header = new MUBHeader(srcBuf); work.mData = GetDATA(); tags = GetTags(); GetFileNameFromTag(); work.fmVoice = GetFMVoiceFromFile(); pcm = GetPCMFromSrcBuf(); if (pcm == null) { GetPCMDataFromFile(); } work.pcmTables = GetPCMTable(); WriteOPNA = opnaWrite; WaitSendOPNA = opnaWaitSend; //PCMを送信する if (pcm != null) { if (isLoadADPCM) { OPNAData[] pcmSendData = GetPCMSendData(); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); foreach (OPNAData dat in pcmSendData) { WriteRegister(dat); } sw.Stop(); WaitSendOPNA(sw.ElapsedMilliseconds, pcmSendData.Length); } } if (loadADPCMOnly) { return; } music2 = new Music2(work, WriteRegister); music2.notSoundBoard2 = notSoundBoard2; }
private void InitT(List <Action <ChipDatum> > lstChipWrite, List <Action <byte[], int, int> > lstChipWriteAdpcm, List <Action <long, int> > chipWaitSend, MmlDatum[] srcBuf, object addtionalOption, Func <string, Stream> appendFileReaderCallback) { if (srcBuf == null || srcBuf.Length < 1) { return; } bool notSoundBoard2 = (bool)((object[])addtionalOption)[0]; bool isLoadADPCM = (bool)((object[])addtionalOption)[1]; bool loadADPCMOnly = (bool)((object[])addtionalOption)[2]; string filename = (string)((object[])addtionalOption)[3]; appendFileReaderCallback = appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(filename)); work = new Work(); header = new MUBHeader(srcBuf, enc); work.mData = GetDATA(); work.header = header; tags = GetTags(); GetFileNameFromTag(); for (int i = 0; i < 4; i++) { work.fmVoice[i] = GetFMVoiceFromFile(i, appendFileReaderCallback); pcm[i] = GetPCMFromSrcBuf(i) ?? GetPCMDataFromFile(i, appendFileReaderCallback); work.pcmTables[i] = GetPCMTable(i); } for (int i = 4; i < 6; i++) { pcm[i] = GetPCMFromSrcBuf(i) ?? GetPCMDataFromFile(i, appendFileReaderCallback); work.pcmTables[i] = GetPCMTable(i); } if (pcm[2] != null && pcmType[2] == "") { TransformOPNAPCMtoOPNBPCM(2); pcmStartPos[2] = 0; } if (pcm[3] != null && pcmType[3] == "") { TransformOPNAPCMtoOPNBPCM(3); pcmStartPos[3] = 0; } if (pcm[4] != null && pcmType[4] == "") { TransformOPNAPCMtoOPNBPCM(4); pcmStartPos[4] = 0; } if (pcm[5] != null && pcmType[5] == "") { TransformOPNAPCMtoOPNBPCM(5); pcmStartPos[5] = 0; } work.isDotNET = IsDotNETFromTAG(); work.SSGExtend = SSGExtendFromTAG(); WriteOPNAP = lstChipWrite[0]; WriteOPNAS = lstChipWrite[1]; WriteOPNBP = lstChipWrite[2]; WriteOPNBS = lstChipWrite[3]; WriteOPMP = lstChipWrite[4]; WriteOPNBAdpcmAP = lstChipWriteAdpcm[2]; WriteOPNBAdpcmBP = lstChipWriteAdpcm[2]; WriteOPNBAdpcmAS = lstChipWriteAdpcm[3]; WriteOPNBAdpcmBS = lstChipWriteAdpcm[3]; WaitSendOPNA = chipWaitSend[0]; //PCMを送信する if (pcm != null) { if (isLoadADPCM) { for (int i = 0; i < 2; i++) { if (pcm[i] == null) { continue; } ChipDatum[] pcmSendData = GetPCMSendData(0, i, 0); var sw = new System.Diagnostics.Stopwatch(); sw.Start(); if (i == 0) { foreach (ChipDatum dat in pcmSendData) { WriteOPNAPRegister(dat); } } if (i == 1) { foreach (ChipDatum dat in pcmSendData) { WriteOPNASRegister(dat); } } sw.Stop(); WaitSendOPNA(sw.ElapsedMilliseconds, pcmSendData.Length); } List <byte> buf = new List <byte>(); if (pcm[2] != null) { buf.Clear(); for (int i = pcmStartPos[2]; i < pcm[2].Length; i++) { buf.Add(pcm[2][i]); } WriteOPNBPAdpcmB(buf.ToArray()); } if (pcm[3] != null) { buf.Clear(); for (int i = pcmStartPos[3]; i < pcm[3].Length; i++) { buf.Add(pcm[3][i]); } WriteOPNBSAdpcmB(buf.ToArray()); } if (pcm[4] != null) { buf.Clear(); for (int i = pcmStartPos[4]; i < pcm[4].Length; i++) { buf.Add(pcm[4][i]); } WriteOPNBPAdpcmA(buf.ToArray()); } if (pcm[5] != null) { buf.Clear(); for (int i = pcmStartPos[5]; i < pcm[5].Length; i++) { buf.Add(pcm[5][i]); } WriteOPNBSAdpcmA(buf.ToArray()); } } } if (loadADPCMOnly) { return; } music2 = new Music2(work, WriteOPNAPRegister, WriteOPNASRegister, WriteOPNBPRegister, WriteOPNBSRegister, WriteOPMPRegister); music2.notSoundBoard2 = notSoundBoard2; }