private static int Save(string name, NDS nds, List <FileSystem.File> sdats, string output)
        {
            BasePlayer player = MakePlayer(name, nds, sdats);

            var wp = new SequenceWaveProviderAdapter(player);

            using (var w = new WaveFileWriter(File.OpenWrite(output), wp.WaveFormat)) {
                var buff = new byte[2048];
                for (int i = 0; i < 200; i++)
                {
                    int written = wp.Read(buff, 0, buff.Length / 2);
                    w.Write(buff, 0, written);
                    if (written < buff.Length / 2)
                    {
                        break;
                    }
                }
            }

            return(ERR_OK);
        }
        private static int Play(BasePlayer player)
        {
            var a  = new NAudio.Wave.DirectSoundOut();
            var wp = new SequenceWaveProviderAdapter(player);

            a.Init(wp);

            a.Play();

            {
                var aType  = a.GetType();
                var field  = aType.GetField("notifyThread", BindingFlags.Instance | BindingFlags.NonPublic);
                var thread = (Thread)field.GetValue(a);
                thread.Name     = "Audio playback Thread";
                thread.Priority = ThreadPriority.Highest;
            }

            Thread.Sleep(10000 * 1000);
            a.Stop();

            return(ERR_OK);
        }