예제 #1
0
파일: SFFile.cs 프로젝트: Bimane1900/Rhythm
        public static void DumpSFToFile(SFData sf, string filename)
        {
            using (StreamWriter writer = File.CreateText(filename))
            {
                foreach (HiPreset p in sf.preset)
                {
                    if (p != null)
                    {
                        writer.WriteLine("Preset itemid:{0} bank:{1} prenum:{2} '{3}'", p.ItemId, p.Bank, p.Num, p.Name);
                        foreach (HiZone z in p.Zone)
                        {
                            if (z.Index < 0)
                            {
                                writer.WriteLine("   PZone itemid:{0} index:{1} Global zone", z.ItemId, z.Index);
                            }
                            else if (z.Index < sf.inst.Length)
                            {
                                writer.WriteLine("   PZone itemid:{0} index:{1} instrument:'{2}'", z.ItemId, z.Index, sf.inst[z.Index].Name);
                            }
                            else
                            {
                                writer.WriteLine("   PZone itemid:{0} index:{1} *** index not in instrument range ***", z.ItemId, z.Index);
                            }

                            if (z.gens != null)
                            {
                                foreach (HiGen g in z.gens)
                                {
                                    if (g.Amount != null)
                                    {
                                        writer.WriteLine("      Gen Id:{0,-20} lo:{1:000} hi:{2:000} sword:{3}", g.type, g.Amount.Lo, g.Amount.Hi, g.Amount.Sword);
                                    }
                                    else
                                    {
                                        writer.WriteLine("      Gen Id:{0,-20} amount is null", g.type);
                                    }
                                }
                            }
                            if (z.mods != null)
                            {
                                foreach (HiMod m in z.mods)
                                {
                                    writer.WriteLine("      Mod amount:{0} {1} {2} {3} {4} ", m.SfSrc, m.Dest, m.SfAmtSrc, m.SfTrans, m.Amount);
                                }
                            }
                        }
                    }
                }

                writer.WriteLine("------------- Instrument -------------");

                foreach (HiInstrument p in sf.inst)
                {
                    //if (p.name.Contains("Mellow"))
                    {
                        writer.WriteLine("Instru itemid:{0} '{1}'", p.ItemId, p.Name);

                        foreach (HiZone z in p.Zone)
                        {
                            if (z.Index < 0)
                            {
                                writer.WriteLine("   IZone itemid:{0} index:{1} Global zone", z.ItemId, z.Index);
                            }
                            else if (z.Index < sf.Samples.Length)
                            {
                                writer.WriteLine("   IZone itemid:{0} index:{1} sample:'{2}'", z.ItemId, z.Index, sf.Samples[z.Index].Name);
                            }
                            else
                            {
                                writer.WriteLine("   IZone itemid:{0} index:{1} *** index not in sample range ***", z.ItemId, z.Index);
                            }


                            if (z.gens != null)
                            {
                                if (z.gens != null)
                                {
                                    foreach (HiGen g in z.gens)
                                    {
                                        if (g.Amount != null)
                                        {
                                            writer.WriteLine("      Gen Id:{0,-20} lo:{1:000} hi:{2:000} sword:{3}", g.type, g.Amount.Lo, g.Amount.Hi, g.Amount.Sword);
                                        }
                                        else
                                        {
                                            writer.WriteLine("      Gen Id:{0,-20} amount is null", g.type);
                                        }
                                    }
                                }
                                if (z.mods != null)
                                {
                                    foreach (HiMod m in z.mods)
                                    {
                                        writer.WriteLine("      Mod amount:{0} {1} {2} {3} {4} ", m.SfSrc, m.Dest, m.SfAmtSrc, m.SfTrans, m.Amount);
                                    }
                                }
                            }
                        }
                    }
                }

                writer.WriteLine("------------- Sample -------------");
                foreach (HiSample s in sf.Samples)
                {
                    writer.WriteLine("itemid:{0} '{1,-20}' start:{2} end:{3} loopstart:{4} loopend:{5} origpitch:{6} pitchadj:{7} samplerate:{8}",
                                     s.ItemId, s.Name, s.Start, s.End, s.LoopStart, s.LoopEnd, s.OrigPitch, s.PitchAdj, s.SampleRate);
                }
            }
        }
예제 #2
0
파일: SFFile.cs 프로젝트: Bimane1900/Rhythm
 static public void Sort(SFData sfdata)
 {
     Array.Sort(sfdata.preset, delegate(HiPreset sp1, HiPreset sp2) { return((sp1.Bank * 256 + sp1.Num).CompareTo(sp2.Bank * 256 + sp2.Num)); });
     //Array.Sort(sfdata.preset, delegate (SFPreset sp1, SFPreset sp2) { return sp1.bank.CompareTo(sp2.bank); });
 }