You can subscribe to this list here.
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(25) |
Jul
(288) |
Aug
(119) |
Sep
(31) |
Oct
(59) |
Nov
(458) |
Dec
(359) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2010 |
Jan
(268) |
Feb
(26) |
Mar
(36) |
Apr
(48) |
May
(119) |
Jun
(37) |
Jul
(173) |
Aug
(429) |
Sep
(137) |
Oct
(156) |
Nov
(59) |
Dec
(45) |
| 2011 |
Jan
(398) |
Feb
(257) |
Mar
(49) |
Apr
(5) |
May
(34) |
Jun
(11) |
Jul
(38) |
Aug
(12) |
Sep
(1) |
Oct
(49) |
Nov
(5) |
Dec
(10) |
| 2012 |
Jan
(21) |
Feb
(32) |
Mar
(20) |
Apr
(1) |
May
(2) |
Jun
|
Jul
(173) |
Aug
|
Sep
(25) |
Oct
(6) |
Nov
(44) |
Dec
|
|
From: Yoda-JM <yo...@us...> - 2011-02-25 15:30:16
|
Author: Vincent Le Ligeour <yo...@us...> Date: Fri Feb 25 16:29:29 2011 +0100 Reduced differences between master and opengl2 branches --- game/glmath.hh | 155 +++++++++++++++++++++ game/glutil.hh | 143 ++++++++++++++++++-- game/guitargraph.cc | 94 +++++++------ game/instrumentgraph.hh | 9 +- game/main.cc | 9 +- game/notegraph.cc | 80 ++++------- game/screen.hh | 2 +- game/screen_intro.cc | 10 ++- game/screen_players.cc | 1 + game/screen_sing.cc | 12 +- game/screen_songs.cc | 102 ++++++++------ game/screen_songs.hh | 3 +- game/screenmanager.cc | 4 +- game/songs.cc | 2 +- game/surface.cc | 2 +- game/surface.hh | 20 ++- game/video_driver.cc | 64 ++++++++- game/video_driver.hh | 13 ++ themes/CMakeLists.txt | 1 - themes/default/songs_bg.svg | 20 ++- themes/default/songs_bg_default.svg | 47 +++++-- themes/default/songs_bg_ground.svg | 260 +++++++++++++++++++++++++++++++++++ 22 files changed, 856 insertions(+), 197 deletions(-) |
|
From: Yoda-JM <yo...@us...> - 2011-02-25 01:24:37
|
Author: Vincent Le Ligeour <yo...@us...>
Date: Fri Feb 25 02:24:16 2011 +0100
Added VBO code (not used for the moment, not working)
---
game/glshader.cc | 31 +++++++++++++++++++++++++++++--
1 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/game/glshader.cc b/game/glshader.cc
index 78e18ad..e11dad7 100644
--- a/game/glshader.cc
+++ b/game/glshader.cc
@@ -140,14 +140,15 @@ GLint Shader::operator[](const std::string& uniform) {
void VertexArray::Draw(GLint mode) {
if (empty()) return;
+ unsigned stride = sizeof(VertexInfo);
+ glmath::Vec4 const* ptr = &m_vertices[0].position;
+#if 1
GLint program;
glGetIntegerv(GL_CURRENT_PROGRAM, &program);
GLint vertPos = glGetAttribLocation(program, "vertPos");
GLint vertTexCoord = glGetAttribLocation(program, "vertTexCoord");
GLint vertNormal = glGetAttribLocation(program, "vertNormal");
GLint vertColor = glGetAttribLocation(program, "vertColor");
- glmath::Vec4 const* ptr = &m_vertices[0].position;
- unsigned stride = sizeof(VertexInfo);
if (vertPos != -1) {
glEnableVertexAttribArray(vertPos);
glVertexAttribPointer(vertPos, 4, GL_FLOAT, GL_FALSE, stride, ptr);
@@ -170,5 +171,31 @@ void VertexArray::Draw(GLint mode) {
if (vertTexCoord != -1) glDisableVertexAttribArray(vertTexCoord);
if (vertNormal != -1) glDisableVertexAttribArray(vertNormal);
if (vertColor != -1) glDisableVertexAttribArray(vertColor);
+#else
+ // VBO
+ glmath::Vec4 const* ptr_ = NULL;
+ GLuint bufferName;
+ glGenBuffers(1, &bufferName);
+ glBindBuffer(GL_ARRAY_BUFFER, bufferName);
+ glBufferData(GL_ARRAY_BUFFER, size(), ptr, GL_STREAM_DRAW);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
+ glEnableClientState(GL_COLOR_ARRAY);
+
+ glVertexPointer(4, GL_FLOAT, stride, ptr_);
+ glTexCoordPointer(4, GL_FLOAT, stride, ptr_ + 1);
+ glNormalPointer(GL_FLOAT, stride, ptr_ + 2);
+ glColorPointer(4, GL_FLOAT, stride, ptr_ + 3);
+ glDrawArrays(mode, 0, size());
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_NORMAL_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+
+ glBindBuffer(GL_ARRAY_BUFFER, bufferName);
+#endif
}
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:55:01
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Feb 25 00:52:33 2011 +0100
Change kbd guitar godmode to RCTRL instead of F6/6/N.
---
game/joystick.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index e18499a..a5c52a9 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -475,7 +475,7 @@ bool input::SDL::pushEvent(SDL_Event _e) {
is_keyboard_event = true;
event.type = input::Event::PRESS;
break;
- case SDLK_F6: case SDLK_6: case SDLK_n:
+ case SDLK_RCTRL: // Godmode
button++;
case SDLK_F5: case SDLK_5: case SDLK_b:
button++;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:54:54
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Feb 25 00:52:33 2011 +0100
Change kbd guitar godmode to RCTRL instead of F6/6/N.
---
game/joystick.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/joystick.cc b/game/joystick.cc
index e18499a..a5c52a9 100644
--- a/game/joystick.cc
+++ b/game/joystick.cc
@@ -475,7 +475,7 @@ bool input::SDL::pushEvent(SDL_Event _e) {
is_keyboard_event = true;
event.type = input::Event::PRESS;
break;
- case SDLK_F6: case SDLK_6: case SDLK_n:
+ case SDLK_RCTRL: // Godmode
button++;
case SDLK_F5: case SDLK_5: case SDLK_b:
button++;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:34:10
|
Author: Lasse Karkkainen <tro...@tr...> Date: Fri Feb 25 00:33:47 2011 +0100 Post a teaser. --- htdocs-source/blog.txt | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/htdocs-source/blog.txt b/htdocs-source/blog.txt index 8413518..44e645b 100644 --- a/htdocs-source/blog.txt +++ b/htdocs-source/blog.txt @@ -1,5 +1,9 @@ News +:h2:2011-02-25 - Did someone say stereo3d? + +<img src="imgs/anaglyph.jpg" alt="Anaglyph screenshot"/> + :h2:2011-02-21 - Song editor 1.0rc1 released An often requested feature for Performous is a song editor and we finally got a chance at implementing one once a Swedish company hired two of the Performous core developers to develop one for them; if more information of this stealth mode start-up is needed - requests can be mailed to bj...@bj.... It was agreed that the editor would be released under the same license as Performous: GNU GPLv2 or later. |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:34:02
|
Author: Lasse Karkkainen <tro...@tr...> Date: Fri Feb 25 00:29:26 2011 +0100 Added stereo3d screenshot --- htdocs-binary/imgs/anaglyph.jpg | Bin 0 -> 83742 bytes 1 files changed, 0 insertions(+), 0 deletions(-) diff --git a/htdocs-binary/imgs/anaglyph.jpg b/htdocs-binary/imgs/anaglyph.jpg new file mode 100644 index 0000000..82e8fc3 Binary files /dev/null and b/htdocs-binary/imgs/anaglyph.jpg differ |
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:14:28
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Feb 25 00:14:13 2011 +0100
Fix guitargraph cursor
---
game/guitargraph.cc | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 4d3b155..38ada22 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -1199,6 +1199,7 @@ void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
/// Draw a bar for drum bass pedal/note
void GuitarGraph::drawBar(double time, float h) {
+ UseShader shader(getShader("color"));
glutil::VertexArray va;
va.Normal(0.0f, 1.0f, 0.0f).TexCoord(0,0).Vertex(-2.5f, time2y(time + h));
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:07:48
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Feb 25 00:07:28 2011 +0100
Another attempt at 3d-fied popups and score calculators.
---
game/guitargraph.cc | 2 ++
game/instrumentgraph.hh | 9 ++++++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 5b31127..4d3b155 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -1156,6 +1156,8 @@ void GuitarGraph::drawDrumfill(float tBeg, float tEnd) {
void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
// Draw info
if (!menuOpen()) {
+ glutil::PushMatrix mat;
+ glTranslatef(0.0f, 0.0f, -0.5f);
float xcor = 0.35 * dimensions.w();
float h = 0.075 * 2.0 * dimensions.w();
// Hack to show the scores better when there is more space (1 instrument)
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index 7b6fd77..85d3585 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -29,13 +29,16 @@ class Popup {
bool draw(double offsetX) {
double anim = m_anim.get();
if (anim > 0.0 && m_popupText) {
- float s = 0.2 * (1.0 + anim);
float a = 1.0 - anim;
m_color.a = a;
glutil::Color color(m_color);
m_popupText->render(m_msg);
- m_popupText->dimensions().center(0.1).middle(offsetX).stretch(s,s);
- m_popupText->draw();
+ {
+ glutil::PushMatrix mat;
+ glTranslatef(0.0f, 0.0f, 0.5f * anim);
+ m_popupText->dimensions().center(0.1 - 0.03 * anim).middle(offsetX).stretch(0.2f, 0.2f);
+ m_popupText->draw();
+ }
if (m_info != "" && m_infoText) {
m_infoText->dimensions.screenBottom(-0.02).middle(-0.12 + offsetX);
m_infoText->draw(m_info, a);
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 23:07:42
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Feb 24 23:18:42 2011 +0100
Revert "A lousy attempt to make guitar score calculator 3d and better positioned."
This reverts commit 8bf1a0e1b3494f789cbf03669c838bdabedd7d85.
---
game/guitargraph.cc | 26 ++++++++++++++------------
game/guitargraph.hh | 2 +-
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 9d99945..5b31127 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -799,7 +799,6 @@ void GuitarGraph::draw(double time) {
glTranslatef(frac * offsetX, 0.0f, 0.0f);
glutil::PushMatrixMode pmb(GL_MODELVIEW);
glTranslatef((1.0 - frac) * offsetX, dimensions.y2(), 0.0f);
- drawInfo(time); // Go draw some texts and other interface stuff
// Do some jumping for drums
if (m_drums) {
float jumpanim = m_drumJump.get();
@@ -1027,6 +1026,7 @@ void GuitarGraph::draw(double time) {
m_neckglow.draw();
}
+ drawInfo(time, offsetX, dimensions); // Go draw some texts and other interface stuff
}
/// Draws a single note
@@ -1153,19 +1153,21 @@ void GuitarGraph::drawDrumfill(float tBeg, float tEnd) {
}
/// Draw popups and other info texts
-void GuitarGraph::drawInfo(double time) {
+void GuitarGraph::drawInfo(double time, double offsetX, Dimensions dimensions) {
// Draw info
if (!menuOpen()) {
- float ycor = -0.05;
- float xcor = 0.50;
- float h = 0.075 * 2.0;
- glutil::PushMatrix pm;
- glTranslatef(0.0f, 0.0f, -2.5f);
+ float xcor = 0.35 * dimensions.w();
+ float h = 0.075 * 2.0 * dimensions.w();
+ // Hack to show the scores better when there is more space (1 instrument)
+ if (m_width.get() > 0.99) {
+ xcor += 0.15;
+ h *= 1.2;
+ }
// Draw scores
{
glutil::Color c(Color(0.1f, 0.3f, 1.0f, 0.90f));
m_scoreText->render((boost::format("%04d") % getScore()).str());
- m_scoreText->dimensions().middle(-xcor).fixedHeight(h).bottom(ycor);
+ m_scoreText->dimensions().middle(-xcor + offsetX).fixedHeight(h).screenBottom(-0.24);
m_scoreText->draw();
}
// Draw streak counter
@@ -1173,24 +1175,24 @@ void GuitarGraph::drawInfo(double time) {
glutil::Color c(Color(0.6f, 0.6f, 0.7f, 0.95f));
m_streakText->render(boost::lexical_cast<std::string>(unsigned(m_streak)) + "/"
+ boost::lexical_cast<std::string>(unsigned(m_longestStreak)));
- m_streakText->dimensions().middle(-xcor).fixedHeight(h*0.75).bottom(ycor);
+ m_streakText->dimensions().middle(-xcor + offsetX).fixedHeight(h*0.75).screenBottom(-0.20);
m_streakText->draw();
}
}
// Is Starpower ready?
if (canActivateStarpower()) {
float a = std::abs(std::fmod(time, 1.0) - 0.5f) * 2.0f;
- m_text.dimensions.screenBottom(-0.02).middle(-0.12);
+ m_text.dimensions.screenBottom(-0.02).middle(-0.12 + offsetX);
if (m_drums && m_dfIt != m_drumfills.end() && time >= m_dfIt->begin && time <= m_dfIt->end)
m_text.draw(_("Drum Fill!"), a);
else m_text.draw(_("God Mode Ready!"), a);
} else if (m_solo) {
// Solo
float a = std::abs(std::fmod(time, 1.0) - 0.5f) * 2.0f;
- m_text.dimensions.screenBottom(-0.02).middle(-0.03);
+ m_text.dimensions.screenBottom(-0.02).middle(-0.03 + offsetX);
m_text.draw(_("Solo!"), a);
}
- drawPopups(0.0f);
+ drawPopups(offsetX);
}
/// Draw a bar for drum bass pedal/note
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 8cf8f27..313b744 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -124,7 +124,7 @@ class GuitarGraph: public InstrumentGraph {
void drawBar(double time, float h);
void drawNote(int fret, Color, float tBeg, float tEnd, float whammy = 0, bool tappable = false, bool hit = false, double hitAnim = 0.0, double releaseTime = 0.0);
void drawDrumfill(float tBeg, float tEnd);
- void drawInfo(double time);
+ void drawInfo(double time, double offsetX, Dimensions dimensions);
float getFretX(int fret) { return (-2.0f + fret- (m_drums ? 0.5 : 0)) * (m_leftymode.b() ? -1 : 1); }
// Chords & notes
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 21:55:06
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 23:54:21 2011 +0200
Click piano, hear what happens.
---
editorapp.cc | 24 ++++++++++++++++++---
editorapp.hh | 5 ++++
notegraphwidget.cc | 7 ++---
notegraphwidget.hh | 1 +
synth.hh | 56 ++++++++++++++++++++++++++--------------------------
5 files changed, 57 insertions(+), 36 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 27a81ba..06593fd 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -984,17 +984,19 @@ void EditorApp::updatePiano(int y)
piano->move(piano->x(), ui.noteGraphScroller->y() - y);
}
-Piano::Piano(QWidget *parent): QLabel(parent) {}
+Piano::Piano(QWidget *parent): QLabel(parent), m_player(new BufferPlayer(this))
+{
+ setMouseTracking(true);
+}
void Piano::updatePixmap(NoteGraphWidget *ngw)
{
- if (!ngw) return;
const int notes = 12 * 4; // Four octaves
const QColor borderColor = QColor("#c0c0c0");
const QColor selectionColor = QColor("#a00");
const QColor mouseColor = QColor("#090");
- int noteHeight = ngw->n2px(0) - ngw->n2px(1);
- int mousen = int(round(ngw->px2n(mapFromGlobal(QCursor::pos()).y())));
+ int noteHeight = 16;
+ int mousen = round((NoteGraphWidget::Height - mapFromGlobal(QCursor::pos()).y()) / 16.0);
QImage image(50, notes * noteHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
@@ -1038,3 +1040,17 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
}
setPixmap(QPixmap::fromImage(image));
}
+
+void Piano::mousePressEvent(QMouseEvent *event)
+{
+ if (!m_player) return;
+ QByteArray ba;
+ int n = round((NoteGraphWidget::Height - event->pos().y()) / 16.0);
+ Synth::createBuffer(ba, n % 12, 0.2);
+ m_player->play(ba);
+}
+
+void Piano::mouseMoveEvent(QMouseEvent *event)
+{
+ updatePixmap(NULL);
+}
diff --git a/editorapp.hh b/editorapp.hh
index 91df56e..35b9f1a 100644
--- a/editorapp.hh
+++ b/editorapp.hh
@@ -34,6 +34,11 @@ public:
Piano(QWidget *parent = 0);
public slots:
void updatePixmap(NoteGraphWidget *ngw);
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+private:
+ BufferPlayer *m_player;
};
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index bde5149..ef9582b 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -24,10 +24,9 @@ namespace {
}
static const double endMarginSeconds = 5.0;
- static const int NoteGraphHeight = 768;
}
-
+/*static*/ const int NoteGraphWidget::Height = 768;
/*static*/ const QString NoteGraphWidget::BGColor = "#222";
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
@@ -40,7 +39,7 @@ NoteGraphWidget::NoteGraphWidget(QWidget *parent)
// Initially expanding horizontally to fill the space
QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed);
setSizePolicy(sp);
- setFixedHeight(NoteGraphHeight);
+ setFixedHeight(Height);
setFocusPolicy(Qt::StrongFocus);
setAcceptDrops(true);
@@ -731,7 +730,7 @@ QString NoteGraphWidget::dumpLyrics() const
SeekHandle::SeekHandle(QWidget *parent)
: QLabel(parent)
{
- QImage image(8, NoteGraphHeight, QImage::Format_ARGB32_Premultiplied);
+ QImage image(8, NoteGraphWidget::Height, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(128, 128, 128, 128));
setPixmap(QPixmap::fromImage(image));
setMouseTracking(true);
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index 14c37e0..80e5cd7 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -109,6 +109,7 @@ class NoteGraphWidget: public NoteLabelManager
public:
static const QString BGColor;
+ static const int Height;
NoteGraphWidget(QWidget *parent = 0);
diff --git a/synth.hh b/synth.hh
index 6462cf0..58f822a 100644
--- a/synth.hh
+++ b/synth.hh
@@ -59,6 +59,32 @@ public:
m_condition.wakeOne();
}
+ /// Creates the sound
+ static void createBuffer(QByteArray &buffer, int note, double length) {
+ // This is simple beep, so we use mono and lowish sample rate
+ // --> quick to create and small memory footprint
+ // Going to 8 bits seems to create weird samples on Windows though
+ std::string header = writeWavHeader(16, 1, sampleRate, length * sampleRate);
+ buffer = QByteArray(header.c_str(), header.size());
+ double d = (note + 1) / 13.0;
+ double freq = MusicalScale().getNoteFreq(note + 12);
+ double phase = 0;
+ // Synthesize tones
+ for (size_t i = 0; i < length * sampleRate; ++i) {
+ float fvalue = d * 0.2 * std::sin(phase) + 0.2 * std::sin(2 * phase) + (1.0 - d) * 0.2 * std::sin(4 * phase);
+ phase += 2.0 * M_PI * freq / sampleRate;
+
+ // Convert float to 16-bit integer and push to buffer
+ qint16 svalue = fvalue * 32768;
+ char* value = reinterpret_cast<char*>(&svalue);
+ buffer.push_back(value[0]);
+ buffer.push_back(value[1]);
+ }
+
+ //std::ofstream of("/tmp/wavdump.wav");
+ //of.write(buf.data(), buf.size());
+ }
+
signals:
void playBuffer(const QByteArray&);
@@ -110,41 +136,15 @@ private:
if (n.begin != m_noteBegin) {
// Need to create a new buffer
m_noteBegin = n.begin;
- createBuffer(n.note % 12, n.length);
+ createBuffer(m_soundData[m_curBuffer], n.note % 12, n.length);
}
// Compensate for the time spent in this function
m_delay -= timer.elapsed() / 1000.0;
if (m_delay <= 0.001) m_delay = 0.001;
}
- /// Creates the sound
- void createBuffer(int note, double length) {
- // This is simple beep, so we use mono and lowish sample rate
- // --> quick to create and small memory footprint
- // Going to 8 bits seems to create weird samples on Windows though
- std::string header = writeWavHeader(16, 1, sampleRate, length * sampleRate);
- m_soundData[m_curBuffer] = QByteArray(header.c_str(), header.size());
- double d = (note + 1) / 13.0;
- double freq = MusicalScale().getNoteFreq(note + 12);
- double phase = 0;
- // Synthesize tones
- for (size_t i = 0; i < length * sampleRate; ++i) {
- float fvalue = d * 0.2 * std::sin(phase) + 0.2 * std::sin(2 * phase) + (1.0 - d) * 0.2 * std::sin(4 * phase);
- phase += 2.0 * M_PI * freq / sampleRate;
-
- // Convert float to 16-bit integer and push to buffer
- qint16 svalue = fvalue * 32768;
- char* value = reinterpret_cast<char*>(&svalue);
- m_soundData[m_curBuffer].push_back(value[0]);
- m_soundData[m_curBuffer].push_back(value[1]);
- }
-
- //std::ofstream of("/tmp/wavdump.wav");
- //of.write(buf.data(), buf.size());
- }
-
/// WAV header writer
- std::string writeWavHeader(unsigned bits, unsigned ch, unsigned sr, unsigned samples) {
+ static std::string writeWavHeader(unsigned bits, unsigned ch, unsigned sr, unsigned samples) {
std::ostringstream out;
unsigned bps = ch * bits / 8; // Bytes per sample
unsigned datasize = bps * samples;
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 21:29:36
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Feb 24 22:29:09 2011 +0100
More detailed GL error checking
---
game/main.cc | 2 --
game/screen_intro.cc | 2 ++
game/video_driver.cc | 7 +++++++
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/game/main.cc b/game/main.cc
index 8fbb531..cc08f5a 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -161,7 +161,6 @@ void mainLoop(std::string const& songlist) {
// Main loop
boost::xtime time = now();
unsigned frames = 0;
- glutil::GLErrorChecker glerror("mainloop");
while (!sm.isFinished()) {
Profiler prof("mainloop");
if( g_take_screenshot ) {
@@ -207,7 +206,6 @@ void mainLoop(std::string const& songlist) {
std::cerr << "ERROR: " << e.what() << std::endl;
sm.flashMessage(std::string("ERROR: ") + e.what());
}
- glerror.check("frame");
}
} catch (std::exception& e) {
// This should use ScreenManager fatalError, but it cannot
diff --git a/game/screen_intro.cc b/game/screen_intro.cc
index 42b473c..f8927fb 100644
--- a/game/screen_intro.cc
+++ b/game/screen_intro.cc
@@ -115,11 +115,13 @@ void ScreenIntro::draw_menu_options() {
}
void ScreenIntro::draw() {
+ glutil::GLErrorChecker glerror("ScreenIntro::draw()");
{
float anim = SDL_GetTicks() % 20000 / 20000.0;
glutil::Color c(glmath::rotate(2.0 * M_PI * anim, glmath::Vec3(1.0, 1.0, 1.0)));
theme->bg.draw();
}
+ glerror.check("bg");
if (m_menu.current().image) m_menu.current().image->draw();
// Comment
theme->comment_bg.dimensions.center().screenBottom(-0.01);
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 79d5e80..2829abe 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -138,6 +138,7 @@ void Window::updateStereo(float sepFactor) {
}
void Window::render(boost::function<void (void)> drawFunc) {
+ glutil::GLErrorChecker glerror("Window::render");
if (s_width < screen->w || s_height < screen->h) glClear(GL_COLOR_BUFFER_BIT); // Black bars
bool stereo = config["graphic/stereo3d"].b();
int type = config["graphic/stereo3dtype"].i();
@@ -147,12 +148,14 @@ void Window::render(boost::function<void (void)> drawFunc) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
updateStereo(stereo ? getSeparation() : 0.0);
+ glerror.check("setup");
// Can we do direct to framebuffer rendering (no FBO)?
if (!stereo || type == 2) { view(stereo); drawFunc(); return; }
// Render both eyes to FBO (full resolution top/bottom)
unsigned w = s_width;
unsigned h = 2 * s_height;
FBO fbo(w, h);
+ glerror.check("FBO");
{
UseFBO user(fbo);
view(0);
@@ -160,12 +163,14 @@ void Window::render(boost::function<void (void)> drawFunc) {
glViewportIndexedf(1, 0, 0, w, h / 2);
drawFunc();
}
+ glerror.check("Render to FBO");
// Render to actual framebuffer from FBOs
UseTexture use(fbo.getTexture());
view(0); // Viewport for drawable area
glDisable(GL_BLEND);
glmath::Matrix colorMatrix;
updateStereo(0.0); // Disable stereo mode while we composite
+ glerror.check("FBO->FB setup");
for (int num = 0; num < 2; ++num) {
{
float saturation = 0.6; // (0..1)
@@ -195,9 +200,11 @@ void Window::render(boost::function<void (void)> drawFunc) {
dim.center((num == 0 ? 0.25 : -0.25) * dim.h());
fbo.getTexture().draw(dim, TexCoords(0.0, h, w, 0));
}
+ glerror.check("FBO->FB postcondition");
}
void Window::view(unsigned num) {
+ glutil::GLErrorChecker glerror("Window::view");
// Set flags
glClearColor (0.0f, 0.0f, 0.0f, 1.0f);
glDisable(GL_DEPTH_TEST);
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 21:29:30
|
Author: Lasse Karkkainen <tro...@tr...>
Date: Thu Feb 24 22:27:04 2011 +0100
Fix a tiny typo that was causing a lot of GL errors.
---
game/glshader.cc | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/game/glshader.cc b/game/glshader.cc
index c01912f..78e18ad 100644
--- a/game/glshader.cc
+++ b/game/glshader.cc
@@ -160,7 +160,7 @@ void VertexArray::Draw(GLint mode) {
glEnableVertexAttribArray(vertNormal);
glVertexAttribPointer(vertNormal, 4, GL_FLOAT, GL_FALSE, stride, ptr + 2);
}
- if (vertColor != 1) {
+ if (vertColor != -1) {
glEnableVertexAttribArray(vertColor);
glVertexAttribPointer(vertColor, 4, GL_FLOAT, GL_FALSE, stride, ptr + 3);
}
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 21:24:06
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 23:23:10 2011 +0200
Display also mouse position on piano keys.
---
editorapp.cc | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 6ebedd9..27a81ba 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -991,8 +991,10 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
if (!ngw) return;
const int notes = 12 * 4; // Four octaves
const QColor borderColor = QColor("#c0c0c0");
- const QColor selectionColor = QColor("#090");
+ const QColor selectionColor = QColor("#a00");
+ const QColor mouseColor = QColor("#090");
int noteHeight = ngw->n2px(0) - ngw->n2px(1);
+ int mousen = int(round(ngw->px2n(mapFromGlobal(QCursor::pos()).y())));
QImage image(50, notes * noteHeight, QImage::Format_ARGB32_Premultiplied);
image.fill(qRgba(0, 0, 0, 0));
@@ -1009,7 +1011,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
int y2 = image.height() - i * noteHeight; // Note center y
y2 -= (scale.isSharp(i + 1) ? 1.0 : 0.5) * noteHeight; // Key top y
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ if (i == mousen) pen.setColor(mouseColor);
+ else if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
else pen.setColor(borderColor);
painter.setPen(pen);
// Skip the first key because y hasn't been calculated yet
@@ -1025,7 +1028,8 @@ void Piano::updatePixmap(NoteGraphWidget *ngw)
if (!scale.isSharp(i)) continue;
y = image.height() - i*noteHeight - noteHeight / 2;
// Pick border color according to selection status
- if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
+ if (i == mousen) pen.setColor(mouseColor);
+ else if (selectionMatches(i, ngw)) pen.setColor(selectionColor);
else pen.setColor(borderColor);
painter.setPen(pen);
painter.fillRect(0, y, w, noteHeight, QColor("#000000"));
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 20:57:26
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 22:56:15 2011 +0200
Fixed note moving producing incorrect pitch into undo op.
---
notegraphwidget.cc | 11 +++++------
notelabelmanager.cc | 6 ++----
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index c9619b2..bde5149 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -415,15 +415,14 @@ void NoteGraphWidget::mouseReleaseEvent(QMouseEvent *event)
if (selectedNote()) {
int movecount = 0;
for (int i = 0; i < m_selectedNotes.size(); ++i) {
- NoteLabel *n = m_selectedNotes[i];
- n->startResizing(0);
- n->startDragging(QPoint());
+ NoteLabel *nl = m_selectedNotes[i];
+ nl->startResizing(0);
+ nl->startDragging(QPoint());
+ const Note& n = nl->note();
if (m_actionHappened) {
// Operation for undo stack & saving
Operation op("MOVE");
- op << getNoteLabelId(n)
- << px2s(n->x()) << px2s(n->x() + n->width())
- << int(round(px2n(n->y() + m_noteHalfHeight)));
+ op << getNoteLabelId(nl) << n.begin << n.end << n.note;
doOperation(op, Operation::NO_EXEC);
++movecount;
}
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 8562c49..7bc695c 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -240,11 +240,9 @@ void NoteLabelManager::move(NoteLabel *note, int value)
int i = 0; // We need this after the loop
for (; i < m_selectedNotes.size(); ++i) {
- NoteLabel *n = m_selectedNotes[i];
+ const Note &n = m_selectedNotes[i]->note();
Operation op("MOVE");
- op << getNoteLabelId(n)
- << px2s(n->x()) << px2s(n->x() + n->width())
- << int(round(px2n(n->y() + m_noteHalfHeight))) + value;
+ op << getNoteLabelId(m_selectedNotes[i]) << n.begin << n.end << n.note + value;
doOperation(op, Operation::NO_UPDATE);
}
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 19:57:02
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 21:55:24 2011 +0200
Fix moving floating notes manually and selecting within selection.
---
notegraphwidget.cc | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 76d4aff..c9619b2 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -397,7 +397,6 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
m_selectedAction = MOVE;
child->startDragging(hotSpot);
}
- child->updatePixmap();
// Middle Click
} else if (event->button() == Qt::MiddleButton) {
@@ -479,9 +478,9 @@ void NoteGraphWidget::mouseDoubleClickEvent(QMouseEvent *event)
void NoteGraphWidget::mouseMoveEvent(QMouseEvent *event)
{
if (!m_actionHappened) {
- m_actionHappened = true; // We have movement, so resize/move can be accepted
// Unfloat all selected notes, otherwise the move would be b0rked by auto-pitch
if (m_selectedAction != NONE && selectedNote()) {
+ m_actionHappened = true; // We have movement, so resize/move can be accepted
// Undo op is handled later by the MOVE constructed at drop
for (int i = 0; i < m_selectedNotes.size(); ++i)
m_selectedNotes[i]->setFloating(false);
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 19:56:55
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 21:40:32 2011 +0200
More NoteLabel pixmap creation based optimizations - really fast now.
---
busydialog.hh | 10 ++++++----
editorapp.cc | 1 +
notegraphwidget.cc | 31 +++++++++++++++++++++++++++----
notegraphwidget.hh | 4 ++++
notelabel.cc | 3 +--
notelabel.hh | 2 +-
notelabelmanager.cc | 3 ++-
7 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/busydialog.hh b/busydialog.hh
index 6d2d5c1..b007c1b 100644
--- a/busydialog.hh
+++ b/busydialog.hh
@@ -18,11 +18,13 @@ public:
timer.start();
}
void operator()() {
- if (count == 0 && isVisible()) // Let's not process events all the time
- QApplication::processEvents();
- count = (count + 1) % interval;
// Only show the dialog after certainamount of time
- if (isHidden() && timer.elapsed() > 1500) open();
+ if (isHidden() && timer.elapsed() > 3000) open();
+ if (isVisible()) {
+ if (count == 0) // Let's not process events all the time
+ QApplication::processEvents();
+ count = (count + 1) % interval;
+ }
}
protected:
void closeEvent(QCloseEvent* event) { event->ignore(); }
diff --git a/editorapp.cc b/editorapp.cc
index eb42c71..6ebedd9 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -221,6 +221,7 @@ void EditorApp::doOpStack()
}
noteGraph->updateNotes();
+ noteGraph->startNotePixmapUpdates();
if (!newMusic.isEmpty()) setMusic(newMusic);
updateMenuStates();
}
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 68dba06..76d4aff 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -32,7 +32,7 @@ namespace {
NoteGraphWidget::NoteGraphWidget(QWidget *parent)
: NoteLabelManager(parent), m_mouseHotSpot(), m_seeking(), m_actionHappened(),
- m_pitch(), m_seekHandle(this), m_analyzeTimer(), m_playbackTimer(), m_playbackPos(), m_pixmap(), m_pixmapPos()
+ m_pitch(), m_seekHandle(this), m_nextNotePixmap(), m_notePixmapTimer(), m_analyzeTimer(), m_playbackTimer(), m_playbackPos(), m_pixmap(), m_pixmapPos()
{
setProperty("darkBackground", true);
setStyleSheet("QLabel[darkBackground=\"true\"] { background: " + BGColor + "; }");
@@ -76,7 +76,7 @@ void NoteGraphWidget::setLyrics(QString lyrics)
if (!word.isEmpty()) {
Note note(word); note.end = NoteLabel::default_length; note.note = 24;
if (sentenceStart) note.lineBreak = true;
- doOperation(opFromNote(note, m_notes.size(), !firstNote));
+ doOperation(opFromNote(note, m_notes.size(), !firstNote), Operation::NO_UPDATE);
firstNote = false;
sentenceStart = false;
}
@@ -96,7 +96,7 @@ void NoteGraphWidget::setLyrics(const VocalTrack &track)
const Notes ¬es = track.notes;
for (Notes::const_iterator it = notes.begin(); it != notes.end(); ++it) {
if (it->type == Note::SLEEP) continue;
- doOperation(opFromNote(*it, m_notes.size(), false));
+ doOperation(opFromNote(*it, m_notes.size(), false), Operation::NO_UPDATE);
busy();
}
@@ -130,6 +130,9 @@ void NoteGraphWidget::finalizeNewLyrics()
// Scroll to show the first note
scrollToFirstNote();
+
+ // Start creating pixmaps for notes
+ startNotePixmapUpdates();
}
void NoteGraphWidget::scrollToFirstNote()
@@ -171,10 +174,30 @@ void NoteGraphWidget::timerEvent(QTimerEvent* event)
killTimer(m_analyzeTimer);
updatePitch();
}
+ } else if (event->timerId() == m_notePixmapTimer) {
+ // Here we create a pixmap for a NoteLabel
+ if (m_nextNotePixmap >= m_notes.size()) {
+ killTimer(m_notePixmapTimer);
+ m_notePixmapTimer = 0;
+ m_nextNotePixmap = 0;
+ return;
+ }
+ // Loop until a pixmap-to-create is found
+ while (m_nextNotePixmap < m_notes.size() && !m_notes[m_nextNotePixmap]->createPixmap())
+ ++m_nextNotePixmap;
+ ++m_nextNotePixmap;
}
}
-void NoteGraphWidget::paintEvent(QPaintEvent*) {
+void NoteGraphWidget::startNotePixmapUpdates()
+{
+ // With 0-delay, note pixmaps are created whenever there is not events to process
+ if (!m_notePixmapTimer) m_notePixmapTimer = startTimer(0);
+ m_nextNotePixmap = 0;
+}
+
+void NoteGraphWidget::paintEvent(QPaintEvent*)
+{
setFixedSize(s2px(m_duration), height());
// Find out the viewport
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index cb6b458..14c37e0 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -36,6 +36,7 @@ public:
NoteLabelManager(QWidget *parent = 0);
virtual void updateNotes(bool leftToRight = true) {}
+ virtual void startNotePixmapUpdates() {}
void clearNotes();
void selectNote(NoteLabel *note, bool clearPrevious = true);
@@ -134,6 +135,7 @@ public slots:
void updatePitch();
void abortPitch() { if (m_pitch) m_pitch->cancel(); }
void scrollToFirstNote();
+ void startNotePixmapUpdates();
signals:
void analyzeProgress(int, int);
@@ -161,6 +163,8 @@ private:
bool m_actionHappened;
QScopedPointer<PitchVis> m_pitch;
SeekHandle m_seekHandle;
+ int m_nextNotePixmap;
+ int m_notePixmapTimer;
int m_analyzeTimer;
int m_playbackTimer;
QElapsedTimer m_playbackInterval;
diff --git a/notelabel.cc b/notelabel.cc
index 74657d9..5c4701b 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -21,8 +21,7 @@ NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, bool floating)
{
updateLabel();
setMouseTracking(true);
- // Deferred graphics generation (to make creation quick as object might also be deleted quickly)
- QTimer::singleShot(render_delay, this, SLOT(createPixmap()));
+ hide();
}
void NoteLabel::updatePixmap()
diff --git a/notelabel.hh b/notelabel.hh
index ab14763..21eec62 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -45,7 +45,7 @@ public:
bool operator<(const NoteLabel &rhs) const { return m_note.begin < rhs.note().begin; }
public slots:
- void createPixmap() { show(); updatePixmap(); }
+ bool createPixmap() { if (isVisible()) return false; show(); updatePixmap(); return true; }
void updatePixmap();
protected:
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 4bf3ed3..8562c49 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -162,7 +162,7 @@ void NoteLabelManager::createNote(double time)
int nlvl = (id > 0) ? m_notes[id-1]->note().note : 24;
QTextStream ts(&text, QIODevice::ReadOnly);
- // Loop throguh all words
+ // Loop through all words
while (!ts.atEnd()) {
QString word;
ts >> word;
@@ -180,6 +180,7 @@ void NoteLabelManager::createNote(double time)
++id;
}
}
+ startNotePixmapUpdates();
}
}
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 18:26:50
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 20:25:55 2011 +0200
Adjust delays.
---
notelabel.cc | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/notelabel.cc b/notelabel.cc
index 91c32c6..74657d9 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -11,7 +11,7 @@ namespace {
static const int text_margin = 3; // Margin of the label texts
}
-const int NoteLabel::render_delay = 200; // How many ms to wait before updating pixmap after some action
+const int NoteLabel::render_delay = 300; // How many ms to wait before updating pixmap after some action
const int NoteLabel::resize_margin = 5; // How many pixels is the resize area
const double NoteLabel::default_length = 0.5; // The preferred size of notes
const double NoteLabel::min_length = 0.05; // How many seconds minimum
@@ -22,7 +22,7 @@ NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, bool floating)
updateLabel();
setMouseTracking(true);
// Deferred graphics generation (to make creation quick as object might also be deleted quickly)
- QTimer::singleShot(500, this, SLOT(createPixmap()));
+ QTimer::singleShot(render_delay, this, SLOT(createPixmap()));
}
void NoteLabel::updatePixmap()
@@ -83,7 +83,7 @@ void NoteLabel::updatePixmap()
void NoteLabel::setSelected(bool state) {
if (m_selected != state) {
m_selected = state;
- QTimer::singleShot(render_delay, this, SLOT(updatePixmap()));
+ QTimer::singleShot(50, this, SLOT(updatePixmap())); // Quick update needed here for box selection
if (!m_selected) {
startResizing(0); // Reset
startDragging(QPoint()); // Reset
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 18:26:42
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 20:25:48 2011 +0200
Remove debug print.
---
editorapp.cc | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 3bed318..eb42c71 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -182,7 +182,7 @@ void EditorApp::doOpStack()
noteGraph->clearNotes();
QString newMusic = "";
OperationStack::iterator opit = opStack.begin();
-QElapsedTimer t; t.start();
+
// Re-apply all operations in the stack
while (opit != opStack.end()) {
//std::cout << "Doing op: " << opit->dump() << std::endl;
@@ -219,7 +219,7 @@ QElapsedTimer t; t.start();
erased = false;
}
}
- std::cout << t.elapsed() << std::endl;
+
noteGraph->updateNotes();
if (!newMusic.isEmpty()) setMusic(newMusic);
updateMenuStates();
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 18:26:33
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 20:11:24 2011 +0200
More optimizations.
---
notelabel.cc | 4 ++--
notelabel.hh | 10 ++++++----
notelabelmanager.cc | 24 ++++++++++++++----------
3 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/notelabel.cc b/notelabel.cc
index 36484e7..91c32c6 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -3,7 +3,6 @@
#include <QToolTip>
#include <QPainter>
#include <QMenu>
-#include <QTimer>
#include <iostream>
#include "notelabel.hh"
#include "notegraphwidget.hh"
@@ -12,6 +11,7 @@ namespace {
static const int text_margin = 3; // Margin of the label texts
}
+const int NoteLabel::render_delay = 200; // How many ms to wait before updating pixmap after some action
const int NoteLabel::resize_margin = 5; // How many pixels is the resize area
const double NoteLabel::default_length = 0.5; // The preferred size of notes
const double NoteLabel::min_length = 0.05; // How many seconds minimum
@@ -83,7 +83,7 @@ void NoteLabel::updatePixmap()
void NoteLabel::setSelected(bool state) {
if (m_selected != state) {
m_selected = state;
- updatePixmap();
+ QTimer::singleShot(render_delay, this, SLOT(updatePixmap()));
if (!m_selected) {
startResizing(0); // Reset
startDragging(QPoint()); // Reset
diff --git a/notelabel.hh b/notelabel.hh
index c054705..ab14763 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -2,6 +2,7 @@
#include <QLabel>
#include <QCloseEvent>
+#include <QTimer>
#include "notes.hh"
#include "operation.hh"
@@ -10,6 +11,7 @@ class NoteLabel: public QLabel
Q_OBJECT
public:
+ static const int render_delay;
static const int resize_margin;
static const double default_length;
static const double min_length;
@@ -17,7 +19,7 @@ public:
NoteLabel(const Note ¬e, QWidget *parent, bool floating = true);
QString lyric() const { return m_note.syllable; }
- void setLyric(const QString &text) { m_note.syllable = text; updatePixmap(); }
+ void setLyric(const QString &text) { m_note.syllable = text; QTimer::singleShot(render_delay, this, SLOT(updatePixmap())); }
QString description(bool multiline) const;
bool isSelected() const { return m_selected; }
@@ -29,10 +31,10 @@ public:
void updateTips();
bool isFloating() const { return m_floating; }
- void setFloating(bool state) { m_floating = state; updatePixmap(); }
+ void setFloating(bool state) { m_floating = state; QTimer::singleShot(render_delay, this, SLOT(updatePixmap())); }
bool isLineBreak() const { return m_note.lineBreak; }
- void setLineBreak(bool state) { m_note.lineBreak = state; updatePixmap(); }
- void setType(int newtype) { m_note.type = Note::types[newtype]; updatePixmap(); }
+ void setLineBreak(bool state) { m_note.lineBreak = state; QTimer::singleShot(render_delay, this, SLOT(updatePixmap())); }
+ void setType(int newtype) { m_note.type = Note::types[newtype]; QTimer::singleShot(render_delay, this, SLOT(updatePixmap())); }
void startResizing(int dir);
void startDragging(const QPoint& point);
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index d675786..4bf3ed3 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -244,13 +244,15 @@ void NoteLabelManager::move(NoteLabel *note, int value)
op << getNoteLabelId(n)
<< px2s(n->x()) << px2s(n->x() + n->width())
<< int(round(px2n(n->y() + m_noteHalfHeight))) + value;
- doOperation(op);
+ doOperation(op, Operation::NO_UPDATE);
}
// Combine to one undo operation
if (i > 1) {
- doOperation(Operation("COMBINER", i));
+ doOperation(Operation("COMBINER", i), Operation::NO_UPDATE);
}
+
+ updateNotes();
}
void NoteLabelManager::setType(NoteLabel *note, int index)
@@ -261,7 +263,8 @@ void NoteLabelManager::setType(NoteLabel *note, int index)
if (note->note().getTypeInt() == index) return;
Operation op("TYPE");
op << getNoteLabelId(note) << index;
- doOperation(op);
+ doOperation(op, Operation::NO_UPDATE);
+ return;
}
// Multiple notes selected: apply to all
@@ -269,9 +272,9 @@ void NoteLabelManager::setType(NoteLabel *note, int index)
for (; i < m_selectedNotes.size(); ++i) {
Operation op("TYPE");
op << getNoteLabelId(m_selectedNotes[i]) << index;
- doOperation(op);
+ doOperation(op, Operation::NO_UPDATE);
}
- doOperation(Operation("COMBINER", i));
+ doOperation(Operation("COMBINER", i), Operation::NO_UPDATE);
}
void NoteLabelManager::setFloating(NoteLabel *note, bool state)
@@ -281,12 +284,13 @@ void NoteLabelManager::setFloating(NoteLabel *note, bool state)
if (m_selectedNotes.size() == 1 || !note->isSelected()) {
if (note->isFloating() == state) return;
doOperation(Operation("FLOATING", getNoteLabelId(note), state));
+ return;
}
// Multiple notes selected: apply to all
int i = 0;
for (; i < m_selectedNotes.size(); ++i) {
- doOperation(Operation("FLOATING", getNoteLabelId(m_selectedNotes[i]), state));
+ doOperation(Operation("FLOATING", getNoteLabelId(m_selectedNotes[i]), state), Operation::NO_UPDATE);
}
doOperation(Operation("COMBINER", i));
}
@@ -297,15 +301,15 @@ void NoteLabelManager::setLineBreak(NoteLabel *note, bool state)
// Easy case: only one note
if (m_selectedNotes.size() == 1 || !note->isSelected()) {
if (note->isLineBreak() == state) return;
- doOperation(Operation("LINEBREAK", getNoteLabelId(note), state));
+ doOperation(Operation("LINEBREAK", getNoteLabelId(note), state), Operation::NO_UPDATE);
}
// Multiple notes selected: apply to all
int i = 0;
for (; i < m_selectedNotes.size(); ++i) {
- doOperation(Operation("LINEBREAK", getNoteLabelId(m_selectedNotes[i]), state));
+ doOperation(Operation("LINEBREAK", getNoteLabelId(m_selectedNotes[i]), state), Operation::NO_UPDATE);
}
- doOperation(Operation("COMBINER", i));
+ doOperation(Operation("COMBINER", i), Operation::NO_UPDATE);
}
void NoteLabelManager::editLyric(NoteLabel *note) {
@@ -321,7 +325,7 @@ void NoteLabelManager::editLyric(NoteLabel *note) {
// Create undo operation
Operation op("LYRIC");
op << getNoteLabelId(note) << text;
- doOperation(op, Operation::NO_EXEC);
+ doOperation(op, Operation::NO_EXEC | Operation::NO_UPDATE);
}
}
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 17:43:50
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 19:42:37 2011 +0200
Further NoteLabel creation optimization: now really defer the pixmap creation.
---
editorapp.cc | 4 ++--
notegraphwidget.cc | 2 +-
notelabel.cc | 11 ++++++-----
notelabel.hh | 13 ++++++++-----
notelabelmanager.cc | 1 -
5 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index eb42c71..3bed318 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -182,7 +182,7 @@ void EditorApp::doOpStack()
noteGraph->clearNotes();
QString newMusic = "";
OperationStack::iterator opit = opStack.begin();
-
+QElapsedTimer t; t.start();
// Re-apply all operations in the stack
while (opit != opStack.end()) {
//std::cout << "Doing op: " << opit->dump() << std::endl;
@@ -219,7 +219,7 @@ void EditorApp::doOpStack()
erased = false;
}
}
-
+ std::cout << t.elapsed() << std::endl;
noteGraph->updateNotes();
if (!newMusic.isEmpty()) setMusic(newMusic);
updateMenuStates();
diff --git a/notegraphwidget.cc b/notegraphwidget.cc
index 47cc182..68dba06 100644
--- a/notegraphwidget.cc
+++ b/notegraphwidget.cc
@@ -374,7 +374,7 @@ void NoteGraphWidget::mousePressEvent(QMouseEvent *event)
m_selectedAction = MOVE;
child->startDragging(hotSpot);
}
- child->createPixmap();
+ child->updatePixmap();
// Middle Click
} else if (event->button() == Qt::MiddleButton) {
diff --git a/notelabel.cc b/notelabel.cc
index 207b6bc..36484e7 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -21,13 +21,13 @@ NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, bool floating)
{
updateLabel();
setMouseTracking(true);
- setAttribute(Qt::WA_DeleteOnClose);
// Deferred graphics generation (to make creation quick as object might also be deleted quickly)
- QTimer::singleShot(2000, this, SLOT(createPixmap()));
+ QTimer::singleShot(500, this, SLOT(createPixmap()));
}
-void NoteLabel::createPixmap()
+void NoteLabel::updatePixmap()
{
+ if (isHidden()) return;
QFont font;
font.setStyleStrategy(QFont::ForceOutline);
QFontMetrics metric(font);
@@ -82,7 +82,8 @@ void NoteLabel::createPixmap()
void NoteLabel::setSelected(bool state) {
if (m_selected != state) {
- m_selected = state; createPixmap();
+ m_selected = state;
+ updatePixmap();
if (!m_selected) {
startResizing(0); // Reset
startDragging(QPoint()); // Reset
@@ -90,7 +91,7 @@ void NoteLabel::setSelected(bool state) {
}
}
-void NoteLabel::resizeEvent(QResizeEvent *) { createPixmap(); }
+void NoteLabel::resizeEvent(QResizeEvent *) { updatePixmap(); }
void NoteLabel::moveEvent(QMoveEvent *) { updateTips(); }
diff --git a/notelabel.hh b/notelabel.hh
index 94602d2..c054705 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -1,6 +1,7 @@
#pragma once
#include <QLabel>
+#include <QCloseEvent>
#include "notes.hh"
#include "operation.hh"
@@ -16,7 +17,7 @@ public:
NoteLabel(const Note ¬e, QWidget *parent, bool floating = true);
QString lyric() const { return m_note.syllable; }
- void setLyric(const QString &text) { m_note.syllable = text; createPixmap(); }
+ void setLyric(const QString &text) { m_note.syllable = text; updatePixmap(); }
QString description(bool multiline) const;
bool isSelected() const { return m_selected; }
@@ -28,10 +29,10 @@ public:
void updateTips();
bool isFloating() const { return m_floating; }
- void setFloating(bool state) { m_floating = state; createPixmap(); }
+ void setFloating(bool state) { m_floating = state; updatePixmap(); }
bool isLineBreak() const { return m_note.lineBreak; }
- void setLineBreak(bool state) { m_note.lineBreak = state; createPixmap(); }
- void setType(int newtype) { m_note.type = Note::types[newtype]; createPixmap(); }
+ void setLineBreak(bool state) { m_note.lineBreak = state; updatePixmap(); }
+ void setType(int newtype) { m_note.type = Note::types[newtype]; updatePixmap(); }
void startResizing(int dir);
void startDragging(const QPoint& point);
@@ -42,12 +43,14 @@ public:
bool operator<(const NoteLabel &rhs) const { return m_note.begin < rhs.note().begin; }
public slots:
- void createPixmap();
+ void createPixmap() { show(); updatePixmap(); }
+ void updatePixmap();
protected:
void resizeEvent(QResizeEvent *event);
void moveEvent(QMoveEvent *event);
void mouseMoveEvent(QMouseEvent *event);
+ void closeEvent(QCloseEvent *event) { deleteLater(); event->accept(); }
private:
Note m_note;
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 5d3f95f..d675786 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -375,7 +375,6 @@ void NoteLabelManager::doOperation(const Operation& op, int flags)
} else {
std::cerr << "Error: Unkown operation type " << action.toStdString() << std::endl;
}
- n->createPixmap();
}
}
} catch (std::runtime_error&) {
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 17:11:58
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 19:06:29 2011 +0200
No constant floating note updating when reapplying opStack.
---
editorapp.cc | 5 +++--
notegraphwidget.hh | 2 +-
notelabelmanager.cc | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index f325737..eb42c71 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -182,6 +182,7 @@ void EditorApp::doOpStack()
noteGraph->clearNotes();
QString newMusic = "";
OperationStack::iterator opit = opStack.begin();
+
// Re-apply all operations in the stack
while (opit != opStack.end()) {
//std::cout << "Doing op: " << opit->dump() << std::endl;
@@ -210,7 +211,7 @@ void EditorApp::doOpStack()
updateSongMeta(true);
} else // Regular note operations
- noteGraph->doOperation(*opit, Operation::NO_EMIT);
+ noteGraph->doOperation(*opit, Operation::NO_EMIT | Operation::NO_UPDATE);
} catch (std::exception& e) { std::cout << e.what() << std::endl; }
if (!erased) {
@@ -219,6 +220,7 @@ void EditorApp::doOpStack()
}
}
+ noteGraph->updateNotes();
if (!newMusic.isEmpty()) setMusic(newMusic);
updateMenuStates();
}
@@ -393,7 +395,6 @@ void EditorApp::openFile(QString fileName)
} catch (const std::exception& e) {
QMessageBox::critical(this, tr("Error loading file!"), e.what());
}
-
}
}
diff --git a/notegraphwidget.hh b/notegraphwidget.hh
index e587d3a..cb6b458 100644
--- a/notegraphwidget.hh
+++ b/notegraphwidget.hh
@@ -59,7 +59,7 @@ public:
void setLineBreak(NoteLabel *note, bool state);
void setType(NoteLabel *note, int newtype);
- void doOperation(const Operation& op, Operation::OperationFlags flags = Operation::NORMAL);
+ void doOperation(const Operation& op, int flags = Operation::NORMAL);
void zoom(float steps, double focalSecs = -1);
int getZoomLevel() const;
diff --git a/notelabelmanager.cc b/notelabelmanager.cc
index 16e30e7..5d3f95f 100644
--- a/notelabelmanager.cc
+++ b/notelabelmanager.cc
@@ -326,7 +326,7 @@ void NoteLabelManager::editLyric(NoteLabel *note) {
}
-void NoteLabelManager::doOperation(const Operation& op, Operation::OperationFlags flags)
+void NoteLabelManager::doOperation(const Operation& op, int flags)
{
if (!(flags & Operation::NO_EXEC)) {
try {
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 17:11:52
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 18:55:16 2011 +0200
Optimize NoteLabel creation by delaying pixmap generation.
---
notelabel.cc | 6 ++++--
notelabel.hh | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/notelabel.cc b/notelabel.cc
index cc5f79e..207b6bc 100644
--- a/notelabel.cc
+++ b/notelabel.cc
@@ -3,6 +3,7 @@
#include <QToolTip>
#include <QPainter>
#include <QMenu>
+#include <QTimer>
#include <iostream>
#include "notelabel.hh"
#include "notegraphwidget.hh"
@@ -18,11 +19,11 @@ const double NoteLabel::min_length = 0.05; // How many seconds minimum
NoteLabel::NoteLabel(const Note ¬e, QWidget *parent, bool floating)
: QLabel(parent), m_note(note), m_selected(false), m_floating(floating), m_resizing(0), m_hotspot()
{
- createPixmap();
updateLabel();
setMouseTracking(true);
setAttribute(Qt::WA_DeleteOnClose);
- show();
+ // Deferred graphics generation (to make creation quick as object might also be deleted quickly)
+ QTimer::singleShot(2000, this, SLOT(createPixmap()));
}
void NoteLabel::createPixmap()
@@ -76,6 +77,7 @@ void NoteLabel::createPixmap()
setPixmap(QPixmap::fromImage(image));
updateTips();
+ show();
}
void NoteLabel::setSelected(bool state) {
diff --git a/notelabel.hh b/notelabel.hh
index 7f4a139..94602d2 100644
--- a/notelabel.hh
+++ b/notelabel.hh
@@ -15,7 +15,6 @@ public:
NoteLabel(const Note ¬e, QWidget *parent, bool floating = true);
- void createPixmap();
QString lyric() const { return m_note.syllable; }
void setLyric(const QString &text) { m_note.syllable = text; createPixmap(); }
QString description(bool multiline) const;
@@ -42,6 +41,9 @@ public:
bool operator<(const NoteLabel &rhs) const { return m_note.begin < rhs.note().begin; }
+public slots:
+ void createPixmap();
+
protected:
void resizeEvent(QResizeEvent *event);
void moveEvent(QMoveEvent *event);
|
|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-24 16:43:07
|
Author: Lasse Kärkkäinen <tronic+ndrm at trn.iki.fi> Date: Thu Feb 24 17:34:41 2011 +0100 Some MIDI writer support --- midifile.cc | 14 +++++++------- midifile.hh | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 11 deletions(-) diff --git a/midifile.cc b/midifile.cc index d359dc5..b4f7102 100644 --- a/midifile.cc +++ b/midifile.cc @@ -33,16 +33,16 @@ bool Reader::nextTrack() { void Reader::parseRiff(char const* name) { if (!std::equal(name, name + 4, m_pos)) throw std::runtime_error("MIDI header " + std::string(name) + " not found, instead found " + std::string(m_pos, m_pos + 4)); m_pos += 4; - unsigned size = read<uint32_t>(); + unsigned size = read<4>(); if (m_fileEnd - m_pos < size) throw std::runtime_error("Unexpected end of file within MIDI header " + std::string(name)); m_riffEnd = m_pos + size; } void Reader::parseMThd() { parseRiff("MThd"); - unsigned fmt = read<uint16_t>(); - m_tracks = read<uint16_t>(); - m_division = read<uint16_t>(); + unsigned fmt = read<2>(); + m_tracks = read<2>(); + m_division = read<2>(); if (fmt == 2) throw std::runtime_error("MIDI format 2 not supported."); if (fmt == 0 && m_tracks == 1) return; // Old single track format if (fmt == 1 && m_tracks > 1) return; // New format (timing info on first track) @@ -61,7 +61,7 @@ bool Reader::parseEvent(Event& ev) { // Event header { ev.timecode = read_varlen(); - unsigned event = read<uint8_t>(); + unsigned event = read<1>(); if (event & 0x80) { if (event < 0xF0) m_runningStatus = event; // Stored for regular (0x00..0xEF) else if (event < 0xF8) m_runningStatus = 0; // Cleared for System Common Category (0xF0..0xF7) @@ -74,7 +74,7 @@ bool Reader::parseEvent(Event& ev) { ev.type = static_cast<Event::Type>(event & 0xF0); ev.channel = event & 0x0F; } - if (ev.type != Event::SPECIAL || ev.channel >= 8) ev.arg1 = read<uint8_t>(); // Everything except System Common takes one argument + if (ev.type != Event::SPECIAL || ev.channel >= 8) ev.arg1 = read<1>(); // Everything except System Common takes one argument unsigned tmp; switch (ev.type) { case Event::NOTE_ON: @@ -82,7 +82,7 @@ bool Reader::parseEvent(Event& ev) { case Event::NOTE_AFTERTOUCH: case Event::CONTROLLER: case Event::PITCH_BEND: - ev.arg2 = read<uint8_t>(); + ev.arg2 = read<1>(); break; case Event::PROGRAM_CHANGE: case Event::CHANNEL_AFTERTOUCH: diff --git a/midifile.hh b/midifile.hh index 3d90431..6dd7718 100644 --- a/midifile.hh +++ b/midifile.hh @@ -66,9 +66,9 @@ namespace mid { void parseMThd(); void parseMTrk(); void parseRiff(char const* name); - template <typename T> T read() { - T value = 0; - for (int i = sizeof(T) - 1; i >= 0; --i) value |= *m_pos++ << (8 * i); + template <unsigned N> unsigned read() { + unsigned value = 0; + for (unsigned i = N - 1; i < N; --i) value |= *m_pos++ << (8 * i); return value; } @@ -91,6 +91,44 @@ namespace mid { unsigned m_division; unsigned m_runningStatus; }; - + + class Writer { + public: + private: + void writeMThd(unsigned tracks, unsigned division) { + beginRiff("MThd"); + write<2>(1); // fmt 1 (multitrack) + write<2>(tracks); + write<2>(division); + endRiff(); + } + void writeMTrk() { + beginRiff("MTrk"); + } + void beginRiff(char const* name) { + m_riffBegin = m_data.size(); + m_data.resize(m_riffBegin + 8); // Add space for header + std::copy(name, name + 4, m_data.begin() + m_riffBegin); // Set RIFF name + } + void endRiff() { + unsigned size = m_data.size() - 8 - m_riffBegin; + m_data[m_riffBegin + 4] = size >> 24; + m_data[m_riffBegin + 5] = size >> 16; + m_data[m_riffBegin + 6] = size >> 8; + m_data[m_riffBegin + 7] = size; + } + template <unsigned N> void write(unsigned value) { + for (unsigned i = N - 1; i < N; --i) m_data.push_back(value >> (8 * i)); + } + void write_varlen(unsigned value) { + if (value >= 0x10000000U) throw std::logic_error("Value cannot be MIDI varlen encoded"); + if (value >= 0x200000U) m_data.push_back(0x80 | (value >> 21)); + if (value >= 0x4000U) m_data.push_back(0x80 | (value >> 14)); + if (value >= 0x80U) m_data.push_back(0x80 | (value >> 7)); + m_data.push_back(value & 0x7F); + } + std::vector<value_type> m_data; + unsigned m_riffBegin; + }; } |
|
From: Tapio V. <aa...@us...> - 2011-02-24 15:36:04
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 17:34:52 2011 +0200
Erase META ops from opStack as they should have been.
---
editorapp.cc | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index 625c3df..f325737 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -181,16 +181,20 @@ void EditorApp::doOpStack()
BusyDialog busy(this, 20);
noteGraph->clearNotes();
QString newMusic = "";
+ OperationStack::iterator opit = opStack.begin();
// Re-apply all operations in the stack
- for (OperationStack::const_iterator opit = opStack.begin(); opit != opStack.end(); ++opit) {
+ while (opit != opStack.end()) {
//std::cout << "Doing op: " << opit->dump() << std::endl;
busy();
+ bool erased = false;
try {
if (opit->op() == "META") {
// META ops are handled differently:
// They are run once and then removed from the stack.
// They are written to disk when saving though.
QString metakey = opit->s(1), metavalue = opit->s(2);
+ opit = opStack.erase(opit);
+ erased = true;
if (metakey == "MUSICFILE") {
newMusic = metavalue;
} else if (metakey == "TITLE") {
@@ -208,6 +212,11 @@ void EditorApp::doOpStack()
} else // Regular note operations
noteGraph->doOperation(*opit, Operation::NO_EMIT);
} catch (std::exception& e) { std::cout << e.what() << std::endl; }
+
+ if (!erased) {
+ ++opit;
+ erased = false;
+ }
}
if (!newMusic.isEmpty()) setMusic(newMusic);
|
|
From: Tapio V. <aa...@us...> - 2011-02-24 11:38:22
|
Author: Tapio Vierros <tap...@gm...>
Date: Thu Feb 24 13:37:02 2011 +0200
Removed a frame decoration.
---
editor.ui | 7 ++-----
1 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/editor.ui b/editor.ui
index 8153983..49333b6 100644
--- a/editor.ui
+++ b/editor.ui
@@ -36,10 +36,10 @@
</sizepolicy>
</property>
<property name="frameShape">
- <enum>QFrame::StyledPanel</enum>
+ <enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
- <enum>QFrame::Raised</enum>
+ <enum>QFrame::Plain</enum>
</property>
<widget class="QScrollArea" name="noteGraphScroller">
<property name="geometry">
@@ -64,9 +64,6 @@
</property>
</widget>
</widget>
- <zorder>noteGraphScroller</zorder>
- <zorder>tabWidget</zorder>
- <zorder>tabWidget</zorder>
</widget>
</item>
<item>
|