Browse Source

Color blocks now displays individual notes on multiple tracks

master
Macoy Madson 5 years ago
parent
commit
02f1229423
  1. 4
      src/SongState.hpp
  2. 36
      src/Visualizers/ColorBlocks.cpp

4
src/SongState.hpp

@ -15,6 +15,8 @@ struct SongTrack
NoteVelocityMap notesPlaying;
};
#define MAX_TRACKS 16
class SongState
{
RtMidiIn MidiIn;
@ -23,7 +25,7 @@ class SongState
void SetNoteOff(MidiNote* noteMessage);
public:
SongTrack Tracks[16];
SongTrack Tracks[MAX_TRACKS];
SongTrack& GetTrack(Channel channel);
SongState();

36
src/Visualizers/ColorBlocks.cpp

@ -1,16 +1,34 @@
#include "ColorBlocks.hpp"
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
void Visualization_ColorBlocksUpdate(window& win, SongState& song)
{
SongTrack& track1 = song.GetTrack(0);
// std::cout << track1.notesPlaying.size() << " notes playing\n";
if (!track1.notesPlaying.empty())
for (int trackIndex = 0; trackIndex < MAX_TRACKS; ++trackIndex)
{
std::cout << "Played a ntoe\n";
win.setBackgroundColor(155, 0, 122, 255);
SongTrack& currentTrack = song.GetTrack(trackIndex);
if (!currentTrack.notesPlaying.empty())
{
win.setBackgroundColor(155, 0, currentTrack.notesPlaying.begin()->first % 256, 255);
int i = 0;
for (NoteVelocityMap::iterator note = currentTrack.notesPlaying.begin();
note != currentTrack.notesPlaying.end(); ++note)
{
sf::RenderWindow* sfWin = win.getBase();
float rectWidth = 10.f;
float rectHeight = 128.f;
sf::RectangleShape rectangle;
rectangle.setSize(sf::Vector2f(rectWidth, rectHeight));
rectangle.setFillColor(sf::Color(0, 0, (note->first * 20) % 256, 255));
rectangle.setPosition(note->first * rectWidth, trackIndex * rectHeight);
sfWin->draw(rectangle);
++i;
}
}
else
win.setBackgroundColor(155, 155, 0, 255);
}
else
win.setBackgroundColor(155, 155, 0, 255);
}

Loading…
Cancel
Save