public void GetSongState(UI.SongInfoControl.SongInfo info) { info.Tempo = _tempo; for (int i = 0; i < 0x10; i++) { Track track = _tracks[i]; if (track.Enabled) { UI.SongInfoControl.SongInfo.Track tin = info.Tracks[i]; tin.Position = Events[i][track.CurEvent].Offset; tin.Rest = track.Rest; tin.Voice = track.Voice; tin.Type = track.Type; tin.Volume = track.Volume; tin.PitchBend = track.GetPitch(); tin.Panpot = track.Panpot; if (track.NoteDuration != 0 && !track.Channel.Stopped) { tin.Keys[0] = track.Channel.Key; ChannelVolume vol = track.Channel.GetVolume(); tin.LeftVolume = vol.LeftVol; tin.RightVolume = vol.RightVol; } else { tin.Keys[0] = byte.MaxValue; tin.LeftVolume = 0f; tin.RightVolume = 0f; } } } }
public void GetSongState(UI.SongInfoControl.SongInfo info) { info.Tempo = _tempo; for (int trackIndex = 0; trackIndex < _tracks.Length; trackIndex++) { Track track = _tracks[trackIndex]; UI.SongInfoControl.SongInfo.Track tin = info.Tracks[trackIndex]; tin.Position = track.CurOffset; tin.Rest = track.Rest; tin.Voice = track.Voice; tin.Type = "PCM"; tin.Volume = track.Volume; tin.PitchBend = track.PitchBend; tin.Extra = track.Octave; tin.Panpot = track.Panpot; Channel[] channels = track.Channels.ToArray(); if (channels.Length == 0) { tin.Keys[0] = byte.MaxValue; tin.LeftVolume = 0f; tin.RightVolume = 0f; //tin.Type = string.Empty; } else { int numKeys = 0; float left = 0f; float right = 0f; for (int j = 0; j < channels.Length; j++) { Channel c = channels[j]; if (!Utils.IsStateRemovable(c.State)) { tin.Keys[numKeys++] = c.Key; } float a = (float)(-c.Panpot + 0x40) / 0x80 * c.Volume / 0x7F; if (a > left) { left = a; } a = (float)(c.Panpot + 0x40) / 0x80 * c.Volume / 0x7F; if (a > right) { right = a; } } tin.Keys[numKeys] = byte.MaxValue; // There's no way for numKeys to be after the last index in the array tin.LeftVolume = left; tin.RightVolume = right; //tin.Type = string.Join(", ", channels.Select(c => c.State.ToString())); } } }