Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feature/duet edit #35

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/editorapp.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <QProgressBar>
#include <QProgressBar>
#include <QPushButton>
#include <QScrollBar>
#include <QMessageBox>
Expand Down Expand Up @@ -496,7 +496,7 @@ void EditorApp::exportSong(QString format, QString dialogTitle)
if (!path.isNull()) {
latestPath = path;
// Sync notes
if (noteGraph) song->insertVocalTrack(TrackName::LEAD_VOCAL, noteGraph->getVocalTrack());
if (noteGraph) song->insertVocalTrack(noteGraph->activeTrack, noteGraph->getVocalTrack());
// Pick exporter
try {
if (format == "XML") SingStarXMLWriter(*song.data(), path);
Expand Down Expand Up @@ -1134,3 +1134,20 @@ void EditorApp::on_sliderPlaybackRate_valueChanged(int value)
}



void EditorApp::on_comboBoxTrack_currentIndexChanged(int index)
{
switch(index) {
case 0:
song->insertVocalTrack(noteGraph->activeTrack, noteGraph->getVocalTrack());
noteGraph->activeTrack = TrackName::LEAD_VOCAL;
noteGraph->setLyrics(song->getVocalTrack(noteGraph->activeTrack));
break;
case 1:
song->insertVocalTrack(noteGraph->activeTrack, noteGraph->getVocalTrack());
noteGraph->activeTrack = TrackName::DUET_P2;
noteGraph->setLyrics(song->getVocalTrack(noteGraph->activeTrack));

break;
}
}
5 changes: 4 additions & 1 deletion src/editorapp.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include "ui_editor.h"
#include "ui_aboutdialog.h"
Expand Down Expand Up @@ -139,6 +139,9 @@ public slots:
protected:
void closeEvent(QCloseEvent *event);

private slots:
void on_comboBoxTrack_currentIndexChanged(int index);

private slots:

private:
Expand Down
4 changes: 2 additions & 2 deletions src/notegraphwidget.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <QMouseEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QScrollArea>
#include <QScrollBar>
Expand Down Expand Up @@ -695,7 +695,7 @@ void NoteGraphWidget::showContextMenu(const QPoint &pos)

VocalTrack NoteGraphWidget::getVocalTrack() const
{
VocalTrack track(TrackName::LEAD_VOCAL);
VocalTrack track(activeTrack);
Notes& notes = track.notes;
if (!m_notes.isEmpty()) {
for (int i = 0; i < m_notes.size(); ++i) {
Expand Down
4 changes: 3 additions & 1 deletion src/notegraphwidget.hh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#pragma once
#pragma once

#include "pitchvis.hh"
#include "notes.hh"
#include "operation.hh"
#include "song.hh"
#include <QLabel>
#include <QList>
#include <QScopedPointer>
Expand Down Expand Up @@ -129,6 +130,7 @@ public:
QString getCurrentSentence() const;
QString getPrevSentence() const;
QString dumpLyrics() const;
QString activeTrack = TrackName::LEAD_VOCAL;

public slots:
void showContextMenu(const QPoint &pos);
Expand Down
2 changes: 1 addition & 1 deletion src/song.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "song.hh"
#include "song.hh"
#include "songparser.hh"
#include "notes.hh"
#include "util.hh"
Expand Down
6 changes: 5 additions & 1 deletion src/song.hh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once

#include <QObject>
#include <QString>
Expand Down Expand Up @@ -29,6 +29,8 @@ namespace TrackName {
const QString BASS = "Bass";
const QString DRUMS = "Drums";
const QString LEAD_VOCAL = "Vocals";
const QString DUET_P2 = "Duet singer";
//const QString DUET_BOTH = "Both singers"; //NOT USED
const QString HARMONIC_1 = "Harmonic 1";
const QString HARMONIC_2 = "Harmonic 2";
const QString HARMONIC_3 = "Harmonic 3";
Expand Down Expand Up @@ -122,6 +124,8 @@ class Song {
QString creator; ///< creator
QString language; ///< language
QString year; ///< year
QString duetsingerP1;
QString duetsingerP2;
QMap<QString,QString> music; ///< music files (background, guitar, rhythm/bass, drums, vocals)
QString cover; ///< cd cover
QString background; ///< background image
Expand Down
30 changes: 27 additions & 3 deletions src/songparser-txt.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "songparser.hh"
#include "songparser.hh"

#include <stdexcept>
#include <iostream>
Expand All @@ -24,13 +24,34 @@ void SongParser::txtParse() {

// Parse notes
VocalTrack vocal(TrackName::LEAD_VOCAL);
while (txtParseNote(line, vocal) && getline(line)) {}
VocalTrack back(TrackName::DUET_P2);
VocalTrack * ActiveVocalTrack = &vocal;
bool finished = false;
while (!finished) {

if(!txtParseNote(line, *ActiveVocalTrack)) {
if(line[0] == 'P') { //P indicator, let's swap tracks
if(line.indexOf('1') != -1) {ActiveVocalTrack = &vocal; m_prevts = 0; m_prevtime = 0; }
if(line.indexOf('2') != -1) {
ActiveVocalTrack = &back;
m_prevts = 0;
m_prevtime = 0;
}
} else {
finished = true;
}
}
if(!getline(line)) {
finished = true;
}
}

// Workaround for the terminating : 1 0 0 line, written by some converters
if (!vocal.notes.empty() && vocal.notes.back().type != Note::SLEEP
&& vocal.notes.back().begin == vocal.notes.back().end) vocal.notes.pop_back();

m_song.insertVocalTrack(TrackName::LEAD_VOCAL, vocal);
m_song.insertVocalTrack(TrackName::DUET_P2, back);
}

bool SongParser::txtParseField(QString const& line) {
Expand Down Expand Up @@ -60,6 +81,9 @@ bool SongParser::txtParseField(QString const& line) {
else if (key == "BPM") m_song.bpm = value.replace(',','.').toDouble(&ok);
else if (key == "LANGUAGE") m_song.language = value;
else if (key == "YEAR") m_song.year = value;
else if (key == "DUETSINGERP1" || key == "P1") m_song.duetsingerP1 = value;
// Strong hint that this is a duet, so it will be readily displayed with two singers in browser and properly filtered
else if (key == "DUETSINGERP2" || key == "P2") m_song.duetsingerP2 = value;

if (!ok) throw std::runtime_error(QString("Invalid value for %1: %2").arg(key).arg(value).toStdString());
return true;
Expand All @@ -84,7 +108,7 @@ bool SongParser::txtParseNote(QString line, VocalTrack &vocal) {
addBPM(ts, bpm);
return true;
}
if (line[0] == 'P') return true; //We ignore player information for now (multiplayer hack)
if (line[0] == 'P') return false; //We ignore player information for now (multiplayer hack)
Note n;
n.type = Note::Type(iss.read(1)[0].toLatin1());
unsigned int ts = m_prevts;
Expand Down
28 changes: 25 additions & 3 deletions src/songwriter-txt.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "songwriter.hh"
#include "songwriter.hh"
#include "config.hh"
#include "util.hh"
#include <QTextStream>
Expand Down Expand Up @@ -42,9 +42,13 @@ void UltraStarTXTWriter::writeTXT() const {
//out << "#RELATIVE:" << "no" << '\n';
//out << "#PREVIEWSTART:" << s.preview_start << '\n';
//if (!s.music["vocals"].isEmpty()) out << "#VOCALS:" << s.music["vocals"] << '\n'; // FIXME: remove full path

bool duet = !s.getVocalTrack(TrackName::DUET_P2).notes.empty();
// Loop through the notes
const Notes& notes = s.getVocalTrack().notes;
Notes notes = s.getVocalTrack(TrackName::LEAD_VOCAL).notes;
if(duet) {
out << "P1:" << '\n';
}
//P1 notes
for (int i = 0; i < notes.size(); ++i) {
const Note& n = notes[i];
if (n.type == Note::SLEEP) continue;
Expand All @@ -59,6 +63,24 @@ void UltraStarTXTWriter::writeTXT() const {
out << (char)n.type << ' '<< sec2dur(n.begin) << ' ' << sec2dur(n.length()) << ' ' << n.note << ' ' << n.syllable << '\n';
}

if(duet) {
notes = s.getVocalTrack(TrackName::DUET_P2).notes;
out << "P2:" << '\n';
for (int i = 0; i < notes.size(); ++i) {
const Note& n = notes[i];
if (n.type == Note::SLEEP) continue;

// Put sleeps between phrases
if (i > 0 && n.lineBreak) {
double ts = 0.5 * (notes[i-1].end + n.begin);
out << "- " << sec2dur(ts) << '\n';
}

// Output the note
out << (char)n.type << ' '<< sec2dur(n.begin) << ' ' << sec2dur(n.length()) << ' ' << n.note << ' ' << n.syllable << '\n';
}
}

out << "E"; // End indicator
}

Expand Down
59 changes: 41 additions & 18 deletions ui/editor.ui
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="chkGrabSeekHandle">
<property name="toolTip">
<string>Make sure the playback cursor is always visible</string>
</property>
<property name="text">
<string>Grab playback</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="cmdSkipSentence">
<property name="toolTip">
Expand Down Expand Up @@ -320,6 +307,42 @@
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="chkGrabSeekHandle">
<property name="toolTip">
<string>Make sure the playback cursor is always visible</string>
</property>
<property name="text">
<string>Grab playback</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QComboBox" name="comboBoxTrack">
<property name="toolTip">
<string>Active Track</string>
</property>
<property name="currentText">
<string>Lead Vocal</string>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<item>
<property name="text">
<string>Lead Vocal</string>
</property>
</item>
<item>
<property name="text">
<string>Duet P2</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabSong">
Expand Down Expand Up @@ -431,7 +454,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>25</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -470,7 +493,7 @@
</property>
<widget class="QMenu" name="menuPreferences">
<property name="title">
<string>P&amp;references</string>
<string>Pr&amp;eferences</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm i think the ampersand shouldn't be here?

</property>
<addaction name="actionAntiAliasing"/>
</widget>
Expand Down Expand Up @@ -625,7 +648,7 @@
</action>
<action name="actionLyricsToFile">
<property name="text">
<string>Lyrics to fi&amp;le...</string>
<string>L&amp;yrics to file...</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm i think the ampersand shouldn't be here?

</property>
</action>
<action name="actionLyricsToClipboard">
Expand Down Expand Up @@ -758,7 +781,7 @@
</action>
<action name="actionAboutQt">
<property name="text">
<string>About Qt...</string>
<string>About &amp;Qt...</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm i think the ampersand shouldn't be here?

</property>
</action>
<action name="actionAdditionalMusicFile">
Expand All @@ -768,7 +791,7 @@
</action>
<action name="actionLyricsFromLRCFile">
<property name="text">
<string>Timed lyrics from LRC/Soramimi file...</string>
<string>&amp;Timed lyrics from LRC/Soramimi file...</string>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm i think the ampersand shouldn't be here?

</property>
</action>
<action name="actionSelectAllAfter">
Expand Down