コード例 #1
0
        public TrackInfo GetTrack(string trackType)
        {
            if (mTrackCache.ContainsKey(trackType))
            {
                return(mTrackCache[trackType]);
            }
            var tagArray1 = DataArrayUtl.FindTagArray(DataArrayUtl.FindTagArray(mData, "tracks"), trackType);
            var tagStr    = DataArrayUtl.FindTagStr(tagArray1, "file");
            var track     = new TrackInfo {
                TrackType = trackType
            };
            var tagInt = DataArrayUtl.FindTagInt(tagArray1, "enabled");

            switch (tagInt)
            {
            case 0:
            case 1:
                track.Enabled = tagInt == 1;
                if (tagStr == "")
                {
                    return(track);
                }
                track.InitFromFile(tagStr, trackType);
                switch (track.NumChannels > 0 ? track.NumChannels : DataArrayUtl.FindTagInt(tagArray1, "channels"))
                {
                case 1:
                    track.PanLeft = DataArrayUtl.FindTagFloat(tagArray1, "pan");
                    track.VolLeft = DataArrayUtl.FindTagFloat(tagArray1, "vol");
                    break;

                case 2:
                    var tagArray2 = DataArrayUtl.FindTagArray(tagArray1, "pan");
                    track.PanLeft  = DataArrayUtl.GetFloat(tagArray2, 1U);
                    track.PanRight = DataArrayUtl.GetFloat(tagArray2, 2U);
                    var tagArray3 = DataArrayUtl.FindTagArray(tagArray1, "vol");
                    track.VolLeft  = DataArrayUtl.GetFloat(tagArray3, 1U);
                    track.VolRight = DataArrayUtl.GetFloat(tagArray3, 2U);
                    break;
                }
                if (!track.IsValid())
                {
                    return(track);
                }
                if (track.NumChannels != DataArrayUtl.FindTagInt(tagArray1, "channels"))
                {
                    track.SetDefaultPan();
                    track.SetDefaultVol();
                    SetTrack(track);
                }
                mTrackCache[trackType] = track;
                return(track);

            default:
                throw new MagmaException("Invalid value for 'enabled' on track " + trackType);
            }
        }
コード例 #2
0
 public void AddTrack(TrackInfo track)
 {
     if (!track.IsValid())
     {
         return;
     }
     Items.Add(new ListViewItem(track.Filename)
     {
         Tag = track
     });
     RefreshTracks();
 }