Пример #1
0
        public override void Render(RenderTarget target, List <Note> notes, MIDIKeyboard keyboard)
        {
            foreach (Note n in notes)
            {
                if (n.Key >= GFXResources.NoteOffset && n.Key < GFXResources.NoteOffset + GFXResources.NoteCount && n.Length > 0 && n.Velocity > 0)
                {
                    // Calculate pitchbend offset to give notes a sliding effect
                    float wheelOffset = (keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * GFXResources.KeyWidth;
                    float bottom      = n.Position + n.Length;
                    float left        = n.Key * GFXResources.KeyWidth + wheelOffset - GFXResources.NoteOffset * GFXResources.KeyWidth;
                    GFXResources.NoteRoundRect.Left   = left;
                    GFXResources.NoteRoundRect.Top    = n.Position;
                    GFXResources.NoteRoundRect.Right  = left + GFXResources.KeyWidth;
                    GFXResources.NoteRoundRect.Bottom = bottom;

                    float alpha = n.Velocity / 127f * (keyboard.ChannelVolume[n.Channel] / 127f);
                    alpha *= alpha; // Square the alpha so differences are more visible and scale quadratically
                    var gradientBrush = GFXResources.ChannelGradientBrushes[n.Channel];
                    gradientBrush.Opacity        = alpha;
                    GFXResources.GradientPoint.X = GFXResources.NoteRoundRect.Left;
                    gradientBrush.StartPoint     = GFXResources.GradientPoint;
                    GFXResources.GradientPoint.X = GFXResources.NoteRoundRect.Right;
                    gradientBrush.EndPoint       = GFXResources.GradientPoint;
                    target.FillRoundedRectangle(GFXResources.ChannelGradientBrushes[n.Channel], GFXResources.NoteRoundRect);
                }
            }
        }
Пример #2
0
 protected override void OnFormClosing(FormClosingEventArgs e)
 {
     Stop(null, null);
     SongPlayer.ShutDown();
     MIDIKeyboard.Stop();
     base.OnFormClosing(e);
 }
Пример #3
0
        public override void Render(RenderTarget target, List <Note> notes, MIDIKeyboard keyboard)
        {
            foreach (Note n in notes)
            {
                if (n.Key >= GFXResources.NoteOffset && n.Key < GFXResources.NoteOffset + GFXResources.NoteCount && n.Length > 0 && n.Velocity > 0)
                {
                    // Calculate pitchbend offset to give notes a sliding effect

                    /* DISABLED FOR PERFORMANCE
                     * float wheelOffset = (keyboard.Pitchwheel[n.Channel] - 8192) / 8192f * 2 * GFXResources.KeyWidth;
                     * float bottom = n.Position + n.Length;
                     * float left = n.Key * GFXResources.KeyWidth + (bottom >= GFXResources.KeyboardY ? wheelOffset : 0) - GFXResources.NoteOffset * GFXResources.KeyWidth;
                     */
                    float left = n.Key * GFXResources.KeyWidth - GFXResources.NoteOffset * GFXResources.KeyWidth;
                    GFXResources.NoteRect.X      = left;
                    GFXResources.NoteRect.Y      = n.Position;
                    GFXResources.NoteRect.Width  = GFXResources.KeyWidth;
                    GFXResources.NoteRect.Height = n.Length;
                    target.FillRectangle(GFXResources.ChannelBrushes[n.Channel], GFXResources.NoteRect);
                }
            }
        }
Пример #4
0
        void LoadSong(object sender, EventArgs e)
        {
            APlaylist    mainPlaylist = ROM.Instance.Game.Playlists[0];
            List <ASong> songs        = mainPlaylist.Songs.ToList();
            ASong        song         = songs.SingleOrDefault(s => s.Index == songNumerical.Value);

            if (song != null)
            {
                Text = "GBA Music Studio - " + song.Name;
                songsComboBox.SelectedIndex = songs.IndexOf(song) + 1; // + 1 for the Playlist index
            }
            else
            {
                Text = "GBA Music Studio";
                songsComboBox.SelectedIndex = 0;
            }
            bool playing = SongPlayer.State == PlayerState.Playing; // Play new song if one is already playing

            Stop(null, null);
            SongPlayer.SetSong(ROM.Instance.SongTables[(int)tableNumerical.Value][(int)songNumerical.Value]);
            UpdateTrackInfo(playing);

            MIDIKeyboard.Start();
        }
Пример #5
0
 public abstract void Render(RenderTarget target, List <Note> notes, MIDIKeyboard keyboard);