if (m_clipType == VIDEO || m_clipType == AV) {
m_hasThumbs = true;
connect(this, SIGNAL(getThumb(int, int)), clip->thumbProducer(), SLOT(extractImage(int, int)));
- connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+ connect(clip->thumbProducer(), SIGNAL(thumbReady(int, QPixmap)), this, SLOT(slotThumbReady(int, QPixmap)));
+ connect(clip, SIGNAL (gotAudioData()), this, SLOT (slotGotAudioData()));
QTimer::singleShot(300, this, SLOT(slotFetchThumbs()));
startThumbTimer = new QTimer(this);
update();
}
+void ClipItem::slotGotAudioData(){
+ update();
+}
+
int ClipItem::type () const
{
return 70000;
}
}
}*/
+ QPen audiopen;
+ audiopen.setWidth(0);
+ painter->setPen(audiopen);
QRectF re=path.boundingRect();
+
+ QMap<int,QPainterPath > channelPaths;
+ QMap<int,QPainterPath > negativeChannelPaths;
+ for (int i=0;i<channels;i++){
+ channelPaths[i].moveTo(re.x(),re.y()+re.height()*i/channels+ (re.height()/channels)/2);
+ negativeChannelPaths[i].moveTo(re.x(),re.y()+re.height()*i/channels+ (re.height()/channels)/2);
+ }
+
for (int samples=re.x();samples<re.x()+re.width();samples++){
double frame=(double)(samples-re.x())/pixelForOneFrame;
int sample=(frame-(int)(frame))*20 ;// AUDIO_FRAME_SIZE
-
if (frame<0 || sample< 0 || sample>19 )
continue;
QMap<int,QByteArray> frame_channel_data=baseClip()->audioFrameChache[(int)frame];
for (int channel=0;channel<channels && frame_channel_data[channel].size()> 0;channel++){
int y=re.y()+re.height()*channel/channels+ (re.height()/channels)/2;
- painter->drawLine(samples , y+frame_channel_data[channel][sample],samples+1, y+frame_channel_data[channel][sample] );
- //painter->drawLine(samples , y+samples-10,samples+1, y+samples-10 );
-
+ channelPaths[channel].lineTo(samples,y+( (int)frame_channel_data[channel][sample] -127/2 ) * (re.height()/channels) / 64 );
+ negativeChannelPaths[channel].lineTo(samples,y-( (int)frame_channel_data[channel][sample] -127/2 ) * (re.height()/channels) / 64 );
}
}
+ for (int i=0;i<channels;i++){
+ //painter->drawPath(channelPaths[i].united(negativeChannelPaths[i]));//or singleif looks better
+ painter->drawPath(channelPaths[i]);
+ }
}
+
+
// draw start / end fades
double scale = br.width() / m_cropDuration;
QBrush fades;
{
audioFrameChache = data;
m_audioThumbCreated = true;
+ emit gotAudioData();
}
QList < GenTime > DocClipBase::snapMarkers() const
}
void DocClipBase::slotGetAudioThumbs(){
- kDebug() << "getting audio data";
+
if (m_audioThumbCreated){
if (m_audioTimer!=NULL)
m_audioTimer->stop();
if (m_audioTimer!=NULL)
m_audioTimer->start(2000);
double lengthInFrames=duration().frames(/*framesPerSecond()*/25);
- m_thumbProd->getAudioThumbs(fileURL(), 1, 0, lengthInFrames /*must be number of frames*/, 20);
+ m_thumbProd->getAudioThumbs(fileURL(), 2, 0, lengthInFrames /*must be number of frames*/, 20);
}
}
int val = 0;
kDebug() << "for " << m_frame << " " << m_frameLength << " " << m_producer.is_valid();
for (int z=(int) m_frame;z<(int) (m_frame+m_frameLength) && m_producer.is_valid();z++){
- kDebug() << "starting audithumb for frame " << z;
-
if (stop_me) break;
val=(int)((z-m_frame)/(m_frame+m_frameLength)*100.0);
if (last_val!=val & val > 1){
QByteArray m_array;
m_array.resize(m_arrayWidth);
for (uint i = 0; i < m_array.size(); i++){
- m_array[i] = qAbs((*( m_pcm + c + i * m_samples / m_array.size() ))>>8);
+ m_array[i] = ( (*( m_pcm + c + i * m_samples / m_array.size() )) >> 9 ) +127/2 ;
}
f.write(m_array);
//FIXME: Hardcoded!!!
int m_frequency = 48000;
int m_channels = channel;
-
m_thumbFile="/tmp/testfile";
- /*FIXME WHY crash here ??????
if (m_url != url) {
m_url = url;
QCryptographicHash context(QCryptographicHash::Sha1);
m_thumbFile = KdenliveSettings::currenttmpfolder() + context.result().toHex() + ".thumb";
- }*/
+ }
QFile f(m_thumbFile);
if (f.open( QIODevice::ReadOnly )) {
emit audioThumbReady(storeIn);
}
else {
- /*if (thumbProducer.isRunning()) return;
+ if (thumbProducer.isRunning()) return;
thumbProducer.init(m_url, m_thumbFile, frame, frameLength, m_frequency, m_channels, arrayWidth);
thumbProducer.start(QThread::LowestPriority );
- */
+
}
}