示例#1
0
        public void AddTrack(TrackInfo track)
        {
            var data = DataArrayUtl.InsertArrayAtEnd(DataArrayUtl.FindTagArray(mData, "tracks"));

            DataArrayUtl.InsertTagIntAtEnd(data, "enabled", track.Enabled ? 1 : 0);
            DataArrayUtl.InsertTagSymAtEnd(data, "type", track.TrackType);
            DataArrayUtl.InsertTagIntAtEnd(data, "channels", track.NumChannels);
            switch (track.NumChannels)
            {
            case 1:
                DataArrayUtl.AddTagFloatAtEnd(data, "pan", track.PanLeft);
                DataArrayUtl.AddTagFloatAtEnd(data, "vol", track.VolLeft);
                break;

            case 2:
                DataArrayUtl.AddTagFloatAtEnd(data, "pan", track.PanLeft);
                DataArrayUtl.AddTagFloatAtEnd(data, "pan", track.PanRight);
                DataArrayUtl.AddTagFloatAtEnd(data, "vol", track.VolLeft);
                DataArrayUtl.AddTagFloatAtEnd(data, "vol", track.VolRight);
                break;

            default:
                throw new MagmaException("Invalid NumChannels: " + track.NumChannels);
            }
            DataArrayUtl.InsertTagStrAtEnd(data, "file", track.Filename);
            OnChangeToUnsavedData();
        }