private void GetPCMData(string path) { Dictionary <int, clsPcm> newDic = new Dictionary <int, clsPcm>(); foreach (clsPcmDatSeq pds in desVGM.instPCMDatSeq) { byte[] buf; clsPcm v; bool isRaw; bool is16bit; int samplerate; if (pds.chip == enmChipType.None) { continue; } switch (pds.type) { case enmPcmDefineType.Easy: if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.chipNumber , pds.FileName , pds.BaseFreq , pds.Volume , 0 , 0 , 0 , pds.DatLoopAdr , false , 8000); desVGM.instPCM.Add(pds.No, v); //ファイルの読み込み buf = Common.GetPCMDataFromFile(path, v, out isRaw, out is16bit, out samplerate); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , v.fileName), new LinePos(pds.FileName)); continue; } //pitch変換 if (desVGM.info.format == enmFormat.XGM) { int fFreq = (int)pds.DatLoopAdr; //SOXで変換する ConvertFreq(path, ref buf, pds.BaseFreq, ref fFreq); pds.BaseFreq = fFreq; v.freq = fFreq; } if (desVGM.info.format == enmFormat.XGM && v.chipNumber != 0) { msgBox.setErrMsg(string.Format( msg.get("E01017") , v.fileName), new LinePos(pds.FileName)); continue; } if (desVGM.chips.ContainsKey(v.chip)) { desVGM.chips[v.chip][v.chipNumber] .StorePcm( newDic , new KeyValuePair <int, clsPcm>(pds.No, v) , buf , is16bit , samplerate); } if (v.chip == enmChipType.YM2609) { if (pds.DatLoopAdr == 0) { //ADPCM-A if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)((YM2609)desVGM.chips[v.chip][v.chipNumber]).pcmDataEasyA.Length - 16; } } else if (pds.DatLoopAdr == 1) { //ADPCM-B if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)((YM2609)desVGM.chips[v.chip][v.chipNumber]).pcmDataEasyB.Length - 16; } } else { //ADPCM-C if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)((YM2609)desVGM.chips[v.chip][v.chipNumber]).pcmDataEasyC.Length - 16; } } } else if (v.chip == enmChipType.YM2610B) { if (pds.DatLoopAdr == 0) { //ADPCM-A if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)((YM2610B)desVGM.chips[v.chip][v.chipNumber]).pcmDataEasyA.Length - 16; } } else { //ADPCM-B if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)((YM2610B)desVGM.chips[v.chip][v.chipNumber]).pcmDataEasyB.Length - 16; } } } else { if (desVGM.chips != null && desVGM.chips.ContainsKey(v.chip) && desVGM.chips[v.chip] != null) { pds.DatEndAdr = (int)desVGM.chips[v.chip][v.chipNumber].pcmDataEasy.Length - 16; } } break; case enmPcmDefineType.Mucom88: if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.chipNumber , pds.FileName , pds.BaseFreq , pds.Volume , 0 , 0 , 0 , pds.DatLoopAdr , false , 8000); desVGM.instPCM.Add(pds.No, v); mucomADPCM2PCM.mucomPCMInfo info = null; for (int i = 0; i < mucomADPCM2PCM.lstMucomPCMInfo.Count; i++) { mucomADPCM2PCM.mucomPCMInfo inf = mucomADPCM2PCM.lstMucomPCMInfo[i]; if (pds.No == inf.no) { info = inf; break; } } if (info == null) { return; } //ファイルの読み込み buf = mucomADPCM2PCM.GetPcmData(info); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , v.fileName), new LinePos(pds.FileName)); continue; } if (desVGM.info.format == enmFormat.XGM && v.chipNumber != 0) { msgBox.setErrMsg(string.Format( msg.get("E01017") , v.fileName), new LinePos(pds.FileName)); continue; } desVGM.chips[v.chip][v.chipNumber] .StorePcm( newDic , new KeyValuePair <int, clsPcm>(pds.No, v) , buf , false , 8000); break; case enmPcmDefineType.RawData: //ファイルの読み込み buf = Common.GetPCMDataFromFile(path, pds.FileName, 100, out isRaw, out is16bit, out samplerate); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , pds.FileName), new LinePos(pds.FileName)); continue; } desVGM.chips[pds.chip][pds.chipNumber] .StorePcmRawData( pds , buf , isRaw , is16bit , samplerate); break; case enmPcmDefineType.Set: //if(!desVGM.chips[pds.chip][pds.chipNumber ? 1 : 0].StorePcmCheck()) //{ // return; //} if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.chipNumber , "" , pds.BaseFreq , 100 , pds.DatStartAdr , pds.DatEndAdr , pds.chip != enmChipType.RF5C164 ? (pds.DatEndAdr - pds.DatStartAdr + 1) : (pds.DatLoopAdr - pds.DatStartAdr + 1) , pds.DatLoopAdr , false , 8000 , pds.Option); newDic.Add(pds.No, v); break; } } desVGM.instPCM = newDic; }
private void GetPCMData(string path) { Dictionary <int, clsPcm> newDic = new Dictionary <int, clsPcm>(); foreach (clsPcmDatSeq pds in desVGM.instPCMDatSeq) { byte[] buf; clsPcm v; bool isRaw; bool is16bit; int samplerate; if (pds.chip == enmChipType.None) { continue; } switch (pds.type) { case enmPcmDefineType.Easy: if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.isSecondary , pds.FileName , pds.BaseFreq , pds.Volume , 0 , 0 , 0 , pds.DatLoopAdr , false , 8000); desVGM.instPCM.Add(pds.No, v); //ファイルの読み込み buf = Common.GetPCMDataFromFile(path, v, out isRaw, out is16bit, out samplerate); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , v.fileName)); continue; } if (desVGM.info.format == enmFormat.XGM && v.isSecondary) { msgBox.setErrMsg(string.Format( msg.get("E01017") , v.fileName)); continue; } desVGM.chips[v.chip][v.isSecondary ? 1 : 0] .StorePcm( newDic , new KeyValuePair <int, clsPcm>(pds.No, v) , buf , is16bit , samplerate); break; case enmPcmDefineType.Mucom88: if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.isSecondary , pds.FileName , pds.BaseFreq , pds.Volume , 0 , 0 , 0 , pds.DatLoopAdr , false , 8000); desVGM.instPCM.Add(pds.No, v); mucomADPCM2PCM.mucomPCMInfo info = null; for (int i = 0; i < mucomADPCM2PCM.lstMucomPCMInfo.Count; i++) { mucomADPCM2PCM.mucomPCMInfo inf = mucomADPCM2PCM.lstMucomPCMInfo[i]; if (pds.No == inf.no) { info = inf; break; } } if (info == null) { return; } //ファイルの読み込み buf = mucomADPCM2PCM.GetPcmData(info, desVGM.info.PcmVolume); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , v.fileName)); continue; } if (desVGM.info.format == enmFormat.XGM && v.isSecondary) { msgBox.setErrMsg(string.Format( msg.get("E01017") , v.fileName)); continue; } desVGM.chips[v.chip][v.isSecondary ? 1 : 0] .StorePcm( newDic , new KeyValuePair <int, clsPcm>(pds.No, v) , buf , false , 8000); break; case enmPcmDefineType.RawData: //ファイルの読み込み buf = Common.GetPCMDataFromFile(path, pds.FileName, 100, out isRaw, out is16bit, out samplerate); if (buf == null) { msgBox.setErrMsg(string.Format( msg.get("E04007") , pds.FileName)); continue; } desVGM.chips[pds.chip][pds.isSecondary ? 1 : 0] .StorePcmRawData( pds , buf , isRaw , is16bit , samplerate); break; case enmPcmDefineType.Set: //if(!desVGM.chips[pds.chip][pds.isSecondary ? 1 : 0].StorePcmCheck()) //{ // return; //} if (desVGM.instPCM.ContainsKey(pds.No)) { desVGM.instPCM.Remove(pds.No); } v = new clsPcm( pds.No , pcmDataSeqNum++ , pds.chip , pds.isSecondary , "" , pds.BaseFreq , 100 , pds.DatStartAdr , pds.DatEndAdr , pds.chip != enmChipType.RF5C164 ? (pds.DatEndAdr - pds.DatStartAdr + 1) : (pds.DatLoopAdr - pds.DatStartAdr + 1) , pds.DatLoopAdr , false , 8000 , pds.Option); newDic.Add(pds.No, v); break; } } desVGM.instPCM = newDic; }