[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Traverso-commit] traverso resources/keymap.xml src/core/AudioCli...
From: |
Remon Sijrier |
Subject: |
[Traverso-commit] traverso resources/keymap.xml src/core/AudioCli... |
Date: |
Mon, 30 Apr 2007 13:50:00 +0000 |
CVSROOT: /sources/traverso
Module name: traverso
Changes by: Remon Sijrier <r_sijrier> 07/04/30 13:50:00
Modified files:
resources : keymap.xml
src/core : AudioClip.cpp AudioClip.h MonoReader.cpp
ReadSource.cpp ReadSource.h
ResourcesManager.cpp
src/traverso/songcanvas: AudioClipView.cpp AudioClipView.h
Log message:
* Added ability to reset file when Resource::init() failed.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/traverso/resources/keymap.xml?cvsroot=traverso&r1=1.62&r2=1.63
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.cpp?cvsroot=traverso&r1=1.84&r2=1.85
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/AudioClip.h?cvsroot=traverso&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/MonoReader.cpp?cvsroot=traverso&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.cpp?cvsroot=traverso&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ReadSource.h?cvsroot=traverso&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/traverso/src/core/ResourcesManager.cpp?cvsroot=traverso&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.cpp?cvsroot=traverso&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/traverso/src/traverso/songcanvas/AudioClipView.h?cvsroot=traverso&r1=1.22&r2=1.23
Patches:
Index: resources/keymap.xml
===================================================================
RCS file: /sources/traverso/traverso/resources/keymap.xml,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- resources/keymap.xml 29 Apr 2007 05:50:39 -0000 1.62
+++ resources/keymap.xml 30 Apr 2007 13:49:59 -0000 1.63
@@ -197,6 +197,7 @@
<Object objectname="SongView"
slotsignature="touch" modes="All" sortorder="2" submenu="Work Cursor"
instantanious="0" />
<Object objectname="TrackPanelLed"
slotsignature="toggle" modes="All" sortorder="1" />
<Object objectname="TrackPanelBus"
slotsignature="TrackView::select_bus" modes="All" instantanious="0" />
+ <Object objectname="AudioClipView"
slotsignature="set_audio_file" modes="All" sortorder="80" instantanious="0" />
</Objects>
</keyfact>
<keyfact type="FKEY" key1="MouseButtonRight" >
Index: src/core/AudioClip.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.cpp,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -b -r1.84 -r1.85
--- src/core/AudioClip.cpp 29 Apr 2007 05:50:40 -0000 1.84
+++ src/core/AudioClip.cpp 30 Apr 2007 13:49:59 -0000 1.85
@@ -107,7 +107,7 @@
m_track = 0;
m_readSource = 0;
m_recordingStatus = NO_RECORDING;
- isSelected = false;
+ isSelected = m_invalidReadSource = false;
fadeIn = 0;
fadeOut = 0;
m_refcount = 0;
@@ -385,8 +385,8 @@
Q_ASSERT(m_readSource);
- if (channel >= m_readSource->get_channel_count()) {
- return -1; // Channel doesn't exist!!
+ if (m_invalidReadSource || (channel >=
m_readSource->get_channel_count())) {
+ return -1;
}
@@ -630,6 +630,13 @@
{
PENTER;
+ int error = rs->get_error();
+ if (error < 0) {
+ m_invalidReadSource = true;
+ } else {
+ m_invalidReadSource = false;
+ }
+
m_readSource = rs;
sourceLength = rs->get_nframes();
@@ -699,7 +706,7 @@
m_recordingStatus = NO_RECORDING;
emit recordingFinished();
} else {
- info().critical(tr("No ReadSource returned from asm
after recording, removing clip from Track!"));
+ info().critical(tr("No ReadSource returned from
resources manager after recording, removing clip from Track!"));
Command::process_command(m_track->remove_clip(this,
false));
}
}
@@ -999,5 +1006,10 @@
return false;
}
+ReadSource * AudioClip::get_readsource() const
+{
+ return m_readSource;
+}
+
// eof
Index: src/core/AudioClip.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/AudioClip.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- src/core/AudioClip.h 26 Apr 2007 18:57:57 -0000 1.44
+++ src/core/AudioClip.h 30 Apr 2007 13:49:59 -0000 1.45
@@ -110,6 +110,7 @@
int get_rate() const;
int get_bitdepth() const;
qint64 get_readsource_id() const;
+ ReadSource* get_readsource() const;
QString get_name() const;
QDomNode get_dom_node() const;
@@ -118,6 +119,7 @@
bool is_take() const;
bool is_selected() const;
bool has_song() const;
+ bool invalid_readsource() const {return m_invalidReadSource;}
int recording_state() const;
static bool smaller(const AudioClip* left, const AudioClip* right )
@@ -156,6 +158,7 @@
int isSelected;
bool isTake;
bool isMuted;
+ bool m_invalidReadSource;
RecordingStatus m_recordingStatus;
float m_gain;
float m_normfactor;
Index: src/core/MonoReader.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/MonoReader.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- src/core/MonoReader.cpp 17 Apr 2007 19:56:46 -0000 1.2
+++ src/core/MonoReader.cpp 30 Apr 2007 13:49:59 -0000 1.3
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: MonoReader.cpp,v 1.2 2007/04/17 19:56:46 r_sijrier Exp $
+$Id: MonoReader.cpp,v 1.3 2007/04/30 13:49:59 r_sijrier Exp $
*/
@@ -97,21 +97,21 @@
if ((m_sf = sf_open (QS_C(m_fileName), SFM_READ, &m_sfinfo)) == 0) {
PERROR("Couldn't open soundfile (%s)", QS_C(m_fileName));
- return -1;
+ return ReadSource::COULD_NOT_OPEN_FILE;
}
if (m_sourceChannelCount > m_sfinfo.channels) {
PERROR("ReadAudioSource: file only contains %d channels; %d is
invalid as a channel number", m_sfinfo.channels, m_sourceChannelCount);
sf_close (m_sf);
m_sf = 0;
- return -1;
+ return ReadSource::INVALID_CHANNEL_COUNT;
}
if (m_sfinfo.channels == 0) {
PERROR("ReadAudioSource: not a valid channel count: %d",
m_sfinfo.channels);
sf_close (m_sf);
m_sf = 0;
- return -1;
+ return ReadSource::ZERO_CHANNELS;
}
m_source->m_length = m_sfinfo.frames;
Index: src/core/ReadSource.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- src/core/ReadSource.cpp 23 Apr 2007 11:52:24 -0000 1.22
+++ src/core/ReadSource.cpp 30 Apr 2007 13:49:59 -0000 1.23
@@ -45,6 +45,7 @@
: AudioSource(node)
, m_sources()
, m_refcount(0)
+ , m_error(0)
{
Project* project = pm().get_project();
@@ -61,6 +62,7 @@
ReadSource::ReadSource(const QString& dir, const QString& name)
: AudioSource(dir, name)
, m_refcount(0)
+ , m_error(0)
{
SNDFILE* sf;
SF_INFO sfinfo;
@@ -78,6 +80,7 @@
ReadSource::ReadSource(const QString& dir, const QString& name, int
channelCount, int fileCount)
: AudioSource(dir, name)
, m_refcount(0)
+ , m_error(0)
{
m_channelCount = channelCount;
m_fileCount = fileCount;
@@ -101,7 +104,7 @@
if (m_channelCount == 0) {
PERROR("ReadSource channel count is 0");
- return -1;
+ return (m_error = INVALID_CHANNEL_COUNT);
}
@@ -109,38 +112,35 @@
if (m_wasRecording) {
if (m_channelCount == 1 && m_fileCount == 1) {
- if (add_mono_reader(1, 0, fileName + "-ch" +
QByteArray::number(0) + ".wav") < 0) {
- return -1;
+ if ( (m_error = add_mono_reader(1, 0, fileName + "-ch"
+ QByteArray::number(0) + ".wav")) < 0) {
+ return m_error;
}
} else if (m_channelCount == 2 && m_fileCount == 2) {
- if ((add_mono_reader(1, 0, fileName + "-ch" +
QByteArray::number(0) + ".wav") < 0) ||
- (add_mono_reader(1, 1, fileName + "-ch" +
QByteArray::number(1) + ".wav") < 0)) {
- return -1;
+ if (((m_error = add_mono_reader(1, 0, fileName + "-ch"
+ QByteArray::number(0) + ".wav") < 0)) ||
+ ((m_error = add_mono_reader(1, 1, fileName +
"-ch" + QByteArray::number(1) + ".wav")) < 0)) {
+ return m_error;
}
} else {
PERROR("WasRecording section: Unsupported combination
of channelcount/filecount (%d/%d)", m_channelCount, m_fileCount);
- return -1;
+ return (m_error = CHANNELCOUNT_FILECOUNT_MISMATCH);
}
} else {
if (m_channelCount == 1 && m_fileCount == 1) {
- if (add_mono_reader(1, 0, fileName) < 0) {
- return -1;
+ if ((m_error = add_mono_reader(1, 0, fileName)) < 0) {
+ return m_error;
}
} else if (m_channelCount == 2 && m_fileCount == 1) {
- if ((add_mono_reader(2, 0, fileName) < 0) ||
- (add_mono_reader(2, 1,
fileName) < 0)) {
- return -1;
+ if (((m_error = add_mono_reader(2, 0, fileName)) < 0)
|| ((m_error = add_mono_reader(2, 1, fileName)) < 0)) {
+ return m_error;
}
} else {
PERROR("Unsupported combination of
channelcount/filecount (%d/%d)", m_channelCount, m_fileCount);
- return -1;
+ return (m_error = CHANNELCOUNT_FILECOUNT_MISMATCH);
}
}
-
-
return 1;
}
@@ -217,5 +217,24 @@
m_wasRecording = wasRecording;
}
-//eof
+int ReadSource::reset_filename(const QString & filename)
+{
+ m_error = 0;
+ int splitpoint = filename.lastIndexOf("/") + 1;
+ int length = filename.length();
+
+ QString dir = filename.left(splitpoint - 1) + "/";
+ QString name = filename.right(length - splitpoint);
+
+ set_dir(dir);
+ set_name(name);
+
+ if (init() < 0) {
+ return -1;
+ }
+
+ return 1;
+}
+
+//eof
Index: src/core/ReadSource.h
===================================================================
RCS file: /sources/traverso/traverso/src/core/ReadSource.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- src/core/ReadSource.h 26 Apr 2007 18:57:57 -0000 1.18
+++ src/core/ReadSource.h 30 Apr 2007 13:49:59 -0000 1.19
@@ -17,7 +17,7 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-$Id: ReadSource.h,v 1.18 2007/04/26 18:57:57 r_sijrier Exp $
+$Id: ReadSource.h,v 1.19 2007/04/30 13:49:59 r_sijrier Exp $
*/
#ifndef READSOURCE_H
@@ -38,6 +38,13 @@
ReadSource(const QString& dir, const QString& name, int channelCount,
int fileCount);
~ReadSource();
+ enum ReadSourceError {
+ COULD_NOT_OPEN_FILE = -1,
+ INVALID_CHANNEL_COUNT = -2,
+ ZERO_CHANNELS = -3,
+ CHANNELCOUNT_FILECOUNT_MISMATCH = -4
+ };
+
ReadSource* deep_copy();
int rb_read(int channel, audio_sample_t* dst, nframes_t start,
nframes_t cnt);
@@ -45,6 +52,8 @@
int init();
int get_ref_count() const {return m_refcount;}
+ int get_error() const {return m_error;}
+ int reset_filename(const QString& filename);
void set_active(bool active);
void set_was_recording(bool wasRecording);
@@ -57,6 +66,7 @@
private:
QList<MonoReader*> m_sources;
int m_refcount;
+ int m_error;
int ref() { return m_refcount++;}
Index: src/core/ResourcesManager.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/core/ResourcesManager.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- src/core/ResourcesManager.cpp 26 Apr 2007 18:57:57 -0000 1.7
+++ src/core/ResourcesManager.cpp 30 Apr 2007 13:49:59 -0000 1.8
@@ -170,7 +170,16 @@
ReadSource* source = new ReadSource(dir, name);
m_sources.insert(source->get_id(), source);
source->set_created_by_song( -1 );
- return get_readsource(source->get_id());
+
+ source = get_readsource(source->get_id());
+
+ if (source->get_error() < 0) {
+ m_sources.remove(source->get_id());
+ delete source;
+ return 0;
+ }
+
+ return source;
}
@@ -202,8 +211,14 @@
source->set_created_by_song( -1 );
}
+ source = get_readsource(source->get_id());
+ if (source->get_error() < 0) {
+ m_sources.remove(source->get_id());
+ delete source;
+ return 0;
+ }
- return get_readsource(source->get_id());
+ return source;
}
ReadSource * ResourcesManager::get_readsource( qint64 id )
@@ -211,6 +226,7 @@
ReadSource* source = m_sources.value(id);
if ( ! source ) {
+ PERROR("ReadSource with id %lld is not in my list!", id);
return 0;
}
@@ -224,11 +240,8 @@
}
if ( source->init() < 0) {
- info().warning( tr( "Failed to initialize ReadSource, removing
from database: %1")
- .arg(source->get_filename()) );
- m_sources.remove(id);
- delete source;
- source = 0;
+ info().warning( tr("ResourcesManager:: Failed to initialize
ReadSource %1")
+ .arg(source->get_filename()));
}
emit stateChanged();
Index: src/traverso/songcanvas/AudioClipView.cpp
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- src/traverso/songcanvas/AudioClipView.cpp 26 Apr 2007 13:46:42 -0000
1.52
+++ src/traverso/songcanvas/AudioClipView.cpp 30 Apr 2007 13:49:59 -0000
1.53
@@ -37,6 +37,8 @@
#include <Curve.h>
#include <Interface.h>
+#include <QFileDialog>
+
// Always put me below _all_ includes, this is needed
// in case we run with memory leak detection enabled!
@@ -123,6 +125,18 @@
clipRect.setHeight(clipRect.height());
painter->setClipRect(clipRect);
+ if (m_clip->invalid_readsource()) {
+ draw_clipinfo_area(painter, xstart, pixelcount);
+ painter->fillRect(xstart, 0, pixelcount, m_height,
themer()->get_color("AudioClip:invalidreadsource"));
+ painter->setPen(themer()->get_color("AudioClip:contour"));
+ painter->drawRect(xstart, 0, pixelcount, m_height - 1);
+ painter->setPen(Qt::black);
+ painter->setFont( QFont( "Bitstream Vera Sans", 11 ) );
+ painter->drawText(30, 0, 300, m_height, Qt::AlignVCenter,
tr("Click to reset AudioFile !"));
+ painter->restore();
+ return;
+ }
+
if (m_drawbackground) {
bool mousehover = (option->state & QStyle::State_MouseOver);
@@ -737,5 +751,37 @@
m_dragging = dragging;
}
+Command * AudioClipView::set_audio_file()
+{
+ if (m_clip->invalid_readsource()) {
+ ReadSource* rs = m_clip->get_readsource();
+ if ( ! rs ) {
+ return ie().failure();
+ }
+
+ QString filename = QFileDialog::getOpenFileName(0,
+ tr("Reset Audio File for Clip:
%1").arg(m_clip->get_name()),
+ rs->get_filename(),
+ tr("All files (*);;Audio files (*.wav
*.flac)"));
+
+ if (filename.isEmpty()) {
+ info().information(tr("No file selected!"));
+ return ie().failure();
+ }
+
+ if (rs->reset_filename(filename) < 0) {
+ return ie().failure();
+ }
+
+ m_clip->set_audio_source(rs);
+
+ info().information(tr("Succesfully set AudioClip file to
%1").arg(filename));
+
+ return ie().succes();
+ }
+
+ return ie().did_not_implement();
+}
+
//eof
Index: src/traverso/songcanvas/AudioClipView.h
===================================================================
RCS file: /sources/traverso/traverso/src/traverso/songcanvas/AudioClipView.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- src/traverso/songcanvas/AudioClipView.h 19 Apr 2007 19:58:39 -0000
1.22
+++ src/traverso/songcanvas/AudioClipView.h 30 Apr 2007 13:49:59 -0000
1.23
@@ -44,6 +44,7 @@
Q_CLASSINFO("select_fade_in_shape", tr("In: Select shape"));
Q_CLASSINFO("select_fade_out_shape", tr("Out: Select shape"));
Q_CLASSINFO("reset_fade", tr("In/Out: Reset"));
+ Q_CLASSINFO("set_audio_file", tr("Reset Audio File"));
public:
AudioClipView(SongView* view, TrackView* parent, AudioClip* clip);
@@ -120,6 +121,7 @@
Command* select_fade_in_shape();
Command* select_fade_out_shape();
Command* reset_fade();
+ Command* set_audio_file();
private slots:
void update_progress_info(int progress);