示例#1
0
 public void Init(string fileName, Action <ChipDatum> oPNAWrite, double sampleRate,
                  MoonDriverDotNETOption dop, string[] vs, Func <string, Stream> appendFileReaderCallback)
 {
     if (Path.GetExtension(fileName).ToLower() != ".xml")
     {
         byte[] srcBuf = File.ReadAllBytes(fileName);
         if (srcBuf == null || srcBuf.Length < 1)
         {
             return;
         }
         Init(fileName, srcBuf, oPNAWrite, sampleRate,
              dop, vs,
              appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
              );
     }
     else
     {
         XmlSerializer serializer = new XmlSerializer(typeof(MmlDatum[]), typeof(MmlDatum[]).GetNestedTypes());
         using (StreamReader sr = new StreamReader(fileName, new UTF8Encoding(false)))
         {
             try
             {
                 MmlDatum[] s = (MmlDatum[])serializer.Deserialize(sr);
                 Init(fileName, s, oPNAWrite, sampleRate,
                      dop, vs, appendFileReaderCallback ?? CreateAppendFileReaderCallback(Path.GetDirectoryName(fileName))
                      );
             }
             catch (System.InvalidOperationException e)
             {
             }
         }
     }
 }
示例#2
0
        public void Init(
            string fileName,
            MmlDatum[] srcBuf,
            Action <ChipDatum> opl4Write,
            double sampleRate,
            MoonDriverDotNETOption addtionalPMDDotNETOption, string[] addtionalPMDOption,
            Func <string, Stream> appendFileReaderCallback
            )
        {
            if (srcBuf == null || srcBuf.Length < 1)
            {
                return;
            }

            Driver.srcBuf = srcBuf;

            WriteOPL4 = opl4Write;

            //work = new PW();
            GetTags();
            //addtionalPMDDotNETOption.PPCHeader = CheckPPC(appendFileReaderCallback);

            //work.SetOption(addtionalPMDDotNETOption, addtionalPMDOption);
            //work.timer = new OPNATimer(44100, 7987200);

            string pcmFn = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pcm");

            byte[] pcmData = null;
            using (Stream s = appendFileReaderCallback(pcmFn))
            {
                pcmData = Common.Common.ReadAllBytes(s);
            }

            //

            md = new MoonDriver();
            if (pcmData != null)
            {
                md.ExtendFile = new Tuple <string, byte[]>(pcmFn, pcmData);
            }
            md.init(srcBuf, WriteRegister, sampleRate);

            //if (!string.IsNullOrEmpty(pmd.pw.ppz1File) || !string.IsNullOrEmpty(pmd.pw.ppz2File)) pmd.pcmload.ppz_load(pmd.pw.ppz1File, pmd.pw.ppz2File);
        }
示例#3
0
        public void Init(
            string fileName,
            byte[] srcBuf,
            Action <ChipDatum> opnaWrite,
            double sampleRate,
            MoonDriverDotNETOption addtionalPMDDotNETOption, string[] addtionalPMDOption,
            Func <string, Stream> appendFileReaderCallback
            )
        {
            if (srcBuf == null || srcBuf.Length < 1)
            {
                return;
            }
            List <MmlDatum> bl = new List <MmlDatum>();

            foreach (byte b in srcBuf)
            {
                bl.Add(new MmlDatum(b));
            }
            Init(fileName, bl.ToArray(), opnaWrite, sampleRate,
                 addtionalPMDDotNETOption, addtionalPMDOption, appendFileReaderCallback);
        }