|
From: Tapio V. <aa...@us...> - 2010-09-14 15:22:50
|
Module: performous
Branch: master
Commit: 334320ad3ccfaa30708328a489cb28c6c22c259f
Author: Tapio Vierros <tap...@gm...>
Date: Tue Sep 14 18:11:06 2010 +0300
Allow mic colors to be assigned in any way wanted.
---
game/audio.cc | 13 +++++++------
game/engine.hh | 14 --------------
game/layout_singer.cc | 2 +-
game/libda/portaudio.hpp | 2 +-
game/player.cc | 11 +++++++++--
5 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/game/audio.cc b/game/audio.cc
index 4ffca83..2fd1aff 100644
--- a/game/audio.cc
+++ b/game/audio.cc
@@ -408,7 +408,7 @@ struct Audio::Impl {
boost::ptr_vector<Device> devices;
boost::ptr_vector<Analyzer> analyzers;
bool playback;
- Impl(): playback() {
+ Impl(): init(), playback() {
// Parse audio devices from config
ConfigItem::StringList devs = config["audio/devices"].sl();
for (ConfigItem::StringList::const_iterator it = devs.begin(), end = devs.end(); it != end; ++it) {
@@ -480,11 +480,12 @@ struct Audio::Impl {
if (analyzers.size() >= 4) break; // Too many mics
std::string const& m = params.mics[j];
if (m.empty()) continue; // Input channel not used
- // TODO: allow assignment in any order (not sequentially like the following code does)
- if (m == "blue" && analyzers.size() != 0) continue;
- if (m == "red" && analyzers.size() != 1) continue;
- if (m == "green" && analyzers.size() != 2) continue;
- if (m == "orange" && analyzers.size() != 3) continue;
+ // Check that the color is not already taken
+ bool mic_used = false;
+ for (size_t mi = 0; mi < analyzers.size(); ++mi) {
+ if (analyzers[mi].getId() == m) { mic_used = true; break; }
+ }
+ if (mic_used) continue;
// Add the new analyzer
Analyzer* a = new Analyzer(d.rate, m);
analyzers.push_back(a);
diff --git a/game/engine.hh b/game/engine.hh
index c2dad6d..88f7061 100644
--- a/game/engine.hh
+++ b/game/engine.hh
@@ -1,24 +1,12 @@
#pragma once
#include "audio.hh"
-#include "color.hh"
#include "song.hh"
#include "configuration.hh"
#include "database.hh"
#include <boost/bind.hpp>
#include <boost/thread/thread.hpp>
#include <list>
-
-namespace {
- const Color playerColors[] = {
- Color(0.2, 0.5, 0.7),
- Color(0.8, 0.3, 0.3),
- Color(0.2, 0.9, 0.2),
- Color(1.0, 0.6, 0.0)
- };
- size_t playerColorsSize = sizeof(playerColors) / sizeof(*playerColors);
-}
-
#include <iostream>
/// performous engine
@@ -51,8 +39,6 @@ class Engine {
// Calculate the space required for pitch frames
size_t frames = vocals.endTime / Engine::TIMESTEP;
while (anBegin != anEnd) m_database.cur.push_back(Player(vocals, *anBegin++, frames));
- size_t player = 0;
- for (std::list<Player>::iterator it = m_database.cur.begin(); it != m_database.cur.end(); ++it, ++player) it->m_color = playerColors[player % playerColorsSize];
}
m_thread.reset(new boost::thread(boost::ref(*this)));
}
diff --git a/game/layout_singer.cc b/game/layout_singer.cc
index 02ec959..54c8297 100644
--- a/game/layout_singer.cc
+++ b/game/layout_singer.cc
@@ -36,7 +36,7 @@ void LayoutSinger::drawScore(Position position) {
float r = p->m_color.r;
float g = p->m_color.g;
float b = p->m_color.b;
- glColor4f(r, g, b,act);
+ glColor4f(r, g, b, act);
m_score_text[i%4]->render((boost::format("%04d") % p->getScore()).str());
switch(position) {
case LayoutSinger::BOTTOM: // Fullscreen
diff --git a/game/libda/portaudio.hpp b/game/libda/portaudio.hpp
index 2104d22..c149203 100644
--- a/game/libda/portaudio.hpp
+++ b/game/libda/portaudio.hpp
@@ -73,7 +73,7 @@ namespace portaudio {
AudioDevices ads;
ads.dump();
}
- ~Init() { Pa_Terminate(); }
+ ~Init() { std::cout << "Pa_Terminate..."; std::cout.flush(); Pa_Terminate(); std::cout << "ok" << std::endl; }
};
struct Params {
diff --git a/game/player.cc b/game/player.cc
index ad56fcc..5c1c625 100644
--- a/game/player.cc
+++ b/game/player.cc
@@ -1,14 +1,21 @@
#include "player.hh"
#include "song.hh"
-
#include "engine.hh" // just for Engine::TIMESTEP
+
Player::Player(VocalTrack& vocals, Analyzer& analyzer, size_t frames):
m_vocals(vocals), m_analyzer(analyzer), m_pitch(frames, std::make_pair(getNaN(),
-getInf())), m_pos(), m_score(), m_noteScore(), m_lineScore(), m_maxLineScore(),
m_prevLineScore(-1), m_feedbackFader(0.0, 2.0), m_activitytimer(),
m_scoreIt(m_vocals.notes.begin())
-{ }
+{
+ // Assign colors
+ if (m_analyzer.getId() == "blue") m_color = Color(0.2, 0.5, 0.7);
+ else if (m_analyzer.getId() == "red") m_color = Color(0.8, 0.3, 0.3);
+ else if (m_analyzer.getId() == "green") m_color = Color(0.2, 0.9, 0.2);
+ else if (m_analyzer.getId() == "orange") m_color = Color(1.0, 0.6, 0.0);
+ else m_color = Color(0.5, 0.5, 0.5);
+}
void Player::update() {
if (m_pos == m_pitch.size()) return; // End of song already
|