rectified waveforms

This commit is contained in:
itsmattkc
2018-08-08 09:16:54 +10:00
parent ce9d7338af
commit 34ae182614
7 changed files with 44 additions and 8 deletions
+6 -2
View File
@@ -15,7 +15,8 @@ Config::Config()
edit_tool_selects_links(false),
edit_tool_also_seeks(false),
select_also_seeks(false),
paste_seeks(true)
paste_seeks(true),
rectified_waveforms(false)
{
}
@@ -52,7 +53,9 @@ void Config::load(QString path) {
} else if (stream.name() == "ImageSequenceFormats") {
stream.readNext();
img_seq_formats = stream.text().toString();
}
} else if (stream.name() == "RectifiedWaveforms") {
rectified_waveforms = (stream.text() == "1");
}
}
}
if (stream.hasError()) {
@@ -106,6 +109,7 @@ void Config::save(QString path) {
stream.writeTextElement("SelectAlsoSeeks", QString::number(select_also_seeks));
stream.writeTextElement("PasteSeeks", QString::number(paste_seeks));
stream.writeTextElement("ImageSequenceFormats", img_seq_formats);
stream.writeTextElement("RectifiedWaveforms", QString::number(rectified_waveforms));
stream.writeEndElement();
stream.writeEndDocument(); // doc
+1
View File
@@ -15,6 +15,7 @@ struct Config {
bool select_also_seeks;
bool paste_seeks;
QString img_seq_formats;
bool rectified_waveforms;
void load(QString path);
void save(QString path);
+7
View File
@@ -558,6 +558,7 @@ void MainWindow::toolMenu_About_To_Be_Shown() {
ui->actionSeek_to_the_End_of_Pastes->setChecked(config.paste_seeks);
ui->actionToggle_Snapping->setChecked(panel_timeline->snapping);
ui->actionScroll_Wheel_Zooms->setChecked(config.scroll_zooms);
ui->actionRectified_Waveforms->setChecked(config.rectified_waveforms);
}
void MainWindow::on_actionEdit_Tool_Selects_Links_triggered() {
@@ -688,3 +689,9 @@ void MainWindow::on_actionTimeline_Track_Lines_triggered()
config.show_track_lines = !config.show_track_lines;
panel_timeline->redraw_all_clips(false);
}
void MainWindow::on_actionRectified_Waveforms_triggered()
{
config.rectified_waveforms = !config.rectified_waveforms;
panel_timeline->redraw_all_clips(false);
}
+2
View File
@@ -168,6 +168,8 @@ private slots:
void on_actionTimeline_Track_Lines_triggered();
void on_actionRectified_Waveforms_triggered();
private:
Ui::MainWindow *ui;
void setup_layout();
+9
View File
@@ -149,6 +149,7 @@
<addaction name="actionEdit_Tool_Selects_Links"/>
<addaction name="actionSeek_to_the_End_of_Pastes"/>
<addaction name="actionScroll_Wheel_Zooms"/>
<addaction name="actionRectified_Waveforms"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="actionCrash"/>
@@ -681,6 +682,14 @@
<string>Ripple Delete In/Out</string>
</property>
</action>
<action name="actionRectified_Waveforms">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Rectified Waveforms</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
+2
View File
@@ -142,6 +142,8 @@ void Viewer::update_sequence() {
update_end_timecode();
}
viewer_widget->repaint();
update();
}
+17 -6
View File
@@ -807,7 +807,7 @@ void TimelineWidget::update_ghosts(QPoint& mouse_pos) {
if (g.clip != -1) c = sequence->get_clip(g.clip);
MediaStream* ms = NULL;
if (c->media_type == MEDIA_TYPE_FOOTAGE) {
if (g.clip != -1 && c->media_type == MEDIA_TYPE_FOOTAGE) {
ms = static_cast<Media*>(c->media)->get_stream_from_file_index(c->media_stream);
}
@@ -1575,13 +1575,15 @@ void TimelineWidget::redraw_clips() {
clip_painter.drawImage(thumb_rect, ms->video_preview);
}
} else if (clip_rect.height() > TRACK_MIN_HEIGHT) {
int divider = ms->audio_channels*2;
clip_painter.setPen(QColor(80, 80, 80));
clip_painter.setPen(QColor(80, 80, 80));
int channel_height = clip_rect.height()/ms->audio_channels;
int divider = ms->audio_channels*2;
int channel_height = clip_rect.height()/ms->audio_channels;
for (int i=0;i<waveform_limit;i++) {
int waveform_index = qFloor((((clip->clip_in + ((double) i/panel_timeline->zoom))/media_length) * ms->audio_preview.size())/divider)*divider;
int waveform_index = qFloor((((clip->clip_in + ((double) i/panel_timeline->zoom))/media_length) * ms->audio_preview.size())/divider)*divider;
int rectified_height = 0;
for (int j=0;j<ms->audio_channels;j++) {
int mid = clip_rect.top()+channel_height*j+(channel_height/2);
@@ -1589,7 +1591,16 @@ void TimelineWidget::redraw_clips() {
qint8 min = (double)ms->audio_preview.at(offset) / 128.0 * (channel_height/2);
qint8 max = (double)ms->audio_preview.at(offset+1) / 128.0 * (channel_height/2);
clip_painter.drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max);
if (config.rectified_waveforms) {
rectified_height += (max - min);
} else {
clip_painter.drawLine(clip_rect.left()+i, mid+min, clip_rect.left()+i, mid+max);
}
}
if (config.rectified_waveforms) {
clip_painter.drawLine(clip_rect.left()+i, clip_rect.height(), clip_rect.left()+i, clip_rect.height() - rectified_height);
}
}
}