added #66
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 4.6.2, 2018-07-09T18:24:32. -->
|
||||
<!-- Written by QtCreator 4.6.2, 2018-07-10T01:01:52. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -222,6 +222,7 @@ void Timeline::update_sequence() {
|
||||
setWindowTitle("Timeline: " + sequence->name);
|
||||
redraw_all_clips(false);
|
||||
playback_updater.setInterval(qFloor(1000 / sequence->frame_rate));
|
||||
reset_all_audio();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -3,8 +3,8 @@
|
||||
|
||||
#include <QVector>
|
||||
|
||||
#define INT16_MAX 0x7fff
|
||||
#define INT16_MIN (-INT16_MAX-1)
|
||||
//#define INT16_MAX 0x7fff
|
||||
//#define INT16_MIN (-INT16_MAX-1)
|
||||
|
||||
class QAudioOutput;
|
||||
class QIODevice;
|
||||
|
||||
+23
-7
@@ -17,11 +17,13 @@ extern "C" {
|
||||
}
|
||||
|
||||
AudioMonitor::AudioMonitor(QWidget *parent) : QWidget(parent) {
|
||||
reset();
|
||||
}
|
||||
|
||||
void AudioMonitor::reset() {
|
||||
sample_cache_offset = -1;
|
||||
sample_cache.clear();
|
||||
update();
|
||||
}
|
||||
|
||||
void AudioMonitor::resizeEvent(QResizeEvent *e) {
|
||||
@@ -38,19 +40,17 @@ void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
int channel_x = AUDIO_MONITOR_GAP;
|
||||
int channel_count = av_get_channel_layout_nb_channels(sequence->audio_layout);
|
||||
int channel_width = (width()/channel_count) - AUDIO_MONITOR_GAP;
|
||||
// for (int i=0;i<channel_count;i++) {
|
||||
for (int i=0;i<1;i++) {
|
||||
long playhead_offset = -1;
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
QRect r(channel_x, 0, channel_width, height());
|
||||
p.fillRect(r, gradient);
|
||||
|
||||
if (sample_cache_offset != -1) {
|
||||
long playhead_offset = panel_timeline->playhead - sample_cache_offset;
|
||||
playhead_offset = (panel_timeline->playhead - sample_cache_offset) * channel_count;
|
||||
if (playhead_offset >= 0 && playhead_offset < sample_cache.size()) {
|
||||
//int channel_offset = i*2;
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset) / 32768.0); // 16-bit int divided to float
|
||||
double multiplier = 1 - qAbs((double) sample_cache.at(playhead_offset+i) / 32768.0); // 16-bit int divided to float
|
||||
r.setHeight(r.height()*multiplier);
|
||||
sample_cache_offset++;
|
||||
sample_cache.removeFirst();
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
@@ -59,5 +59,21 @@ void AudioMonitor::paintEvent(QPaintEvent *) {
|
||||
p.fillRect(r, QColor(0, 0, 0, 160));
|
||||
channel_x += channel_width + AUDIO_MONITOR_GAP;
|
||||
}
|
||||
if (playhead_offset > -1) {
|
||||
// clean up used samples
|
||||
bool error = false;
|
||||
while (sample_cache_offset < panel_timeline->playhead && !error) {
|
||||
sample_cache_offset++;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
if (sample_cache.isEmpty()) {
|
||||
reset();
|
||||
error = true;
|
||||
break;
|
||||
} else {
|
||||
sample_cache.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#define AUDIO_MONITOR_RESOLUTION 16
|
||||
|
||||
class AudioMonitor : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
+22
-9
@@ -51,7 +51,7 @@ void TimelineWidget::resizeEvent(QResizeEvent*) {
|
||||
}
|
||||
|
||||
void TimelineWidget::dragEnterEvent(QDragEnterEvent *event) {
|
||||
if (static_cast<SourceTable*>(event->source()) == panel_project->source_table) {
|
||||
if (event->source() == panel_project->source_table) {
|
||||
event->accept();
|
||||
QPoint pos = event->pos();
|
||||
QList<QTreeWidgetItem*> items = panel_project->source_table->selectedItems();
|
||||
@@ -138,9 +138,22 @@ void TimelineWidget::dropEvent(QDropEvent* event) {
|
||||
c->timeline_in = g.in;
|
||||
c->timeline_out = g.out;
|
||||
c->clip_in = g.clip_in;
|
||||
c->color_r = 128;
|
||||
c->color_g = 128;
|
||||
c->color_b = 192;
|
||||
if (c->media->video_tracks.size() == 0) {
|
||||
// audio only (greenish)
|
||||
c->color_r = 128;
|
||||
c->color_g = 192;
|
||||
c->color_b = 128;
|
||||
} else if (c->media->audio_tracks.size() == 0) {
|
||||
// video only (purpleish)
|
||||
c->color_r = 192;
|
||||
c->color_g = 128;
|
||||
c->color_b = 128;
|
||||
} else {
|
||||
// video and audio (blueish)
|
||||
c->color_r = 128;
|
||||
c->color_g = 128;
|
||||
c->color_b = 192;
|
||||
}
|
||||
c->sequence = sequence;
|
||||
c->track = g.track;
|
||||
c->name = c->media->name;
|
||||
@@ -1212,12 +1225,12 @@ void TimelineWidget::redraw_clips() {
|
||||
clip_painter.drawLine(text_rect.x(), underline_y, text_rect.x() + underline_width, underline_y);
|
||||
}
|
||||
clip_painter.drawText(text_rect, 0, clip->name, &text_rect);
|
||||
|
||||
// bottom right gray
|
||||
clip_painter.setPen(Qt::gray);
|
||||
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight());
|
||||
clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight());
|
||||
}
|
||||
|
||||
// bottom right gray
|
||||
clip_painter.setPen(QColor(0, 0, 0, 128));
|
||||
clip_painter.drawLine(clip_rect.bottomLeft(), clip_rect.bottomRight());
|
||||
clip_painter.drawLine(clip_rect.bottomRight(), clip_rect.topRight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+18
-4
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QtMath>
|
||||
|
||||
extern "C" {
|
||||
#include <libavformat/avformat.h>
|
||||
@@ -184,11 +185,24 @@ void ViewerWidget::paintGL() {
|
||||
panel_timeline->ui->audio_monitor->sample_cache_offset = panel_timeline->playhead;
|
||||
}
|
||||
long sample_cache_playhead = panel_timeline->ui->audio_monitor->sample_cache_offset + panel_timeline->ui->audio_monitor->sample_cache.size();
|
||||
int buffer_offset, buffer_offset_adjusted;
|
||||
while ((buffer_offset = get_buffer_offset_from_frame(sample_cache_playhead)) < audio_ibuffer_read) {
|
||||
buffer_offset_adjusted = (buffer_offset)%audio_ibuffer_size;
|
||||
panel_timeline->ui->audio_monitor->sample_cache.append((qint16) ((audio_ibuffer[buffer_offset_adjusted+1] << 8) | audio_ibuffer[buffer_offset_adjusted]));
|
||||
int next_buffer_offset, buffer_offset_adjusted, i;
|
||||
int buffer_offset = get_buffer_offset_from_frame(sample_cache_playhead);
|
||||
samples.resize(av_get_channel_layout_nb_channels(sequence->audio_layout));
|
||||
samples.fill(0);
|
||||
while (buffer_offset < audio_ibuffer_read) {
|
||||
sample_cache_playhead++;
|
||||
next_buffer_offset = qMin(get_buffer_offset_from_frame(sample_cache_playhead), audio_ibuffer_read);
|
||||
while (buffer_offset < next_buffer_offset) {
|
||||
for (i=0;i<samples.size();i++) {
|
||||
buffer_offset_adjusted = buffer_offset%audio_ibuffer_size;
|
||||
samples[i] = qMax(qAbs((qint16) (((audio_ibuffer[buffer_offset_adjusted+1] & 0xFF) << 8) | (audio_ibuffer[buffer_offset_adjusted] & 0xFF))), samples[i]);
|
||||
buffer_offset += 2;
|
||||
}
|
||||
}
|
||||
for (i=0;i<samples.size();i++) {
|
||||
panel_timeline->ui->audio_monitor->sample_cache.append(samples.at(i));
|
||||
}
|
||||
buffer_offset = next_buffer_offset;
|
||||
}
|
||||
|
||||
memset(audio_ibuffer+adjusted_read_index, 0, actual_write);
|
||||
|
||||
@@ -29,6 +29,7 @@ protected:
|
||||
private:
|
||||
QTimer retry_timer;
|
||||
QVector<Clip*> current_clips;
|
||||
QVector<qint16> samples;
|
||||
private slots:
|
||||
void retry();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user