changeset 351:36efd75d7b7b tonioni

Merge from default branch
author Chris Cannam
date Wed, 14 May 2014 09:58:27 +0100
parents 63dec7dc11cc (current diff) aebee52e86b3 (diff)
children 5a66f4e5a3dc
files
diffstat 8 files changed, 53 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/audioio/AudioGenerator.cpp	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/AudioGenerator.cpp	Wed May 14 09:58:27 2014 +0100
@@ -48,7 +48,7 @@
 AudioGenerator::AudioGenerator() :
     m_sourceSampleRate(0),
     m_targetChannelCount(1),
-	m_waveType(0),
+    m_waveType(0),
     m_soloing(false)
 {
     initialiseSampleDir();
@@ -173,6 +173,18 @@
 }
 
 bool
+AudioGenerator::wantsQuieterClips(const Model *model)
+{
+    // basically, anything that usually has sustain (like notes) or
+    // often has multiple sounds at once (like notes) wants to use a
+    // quieter level than simple click tracks
+    bool does = 
+        (qobject_cast<const NoteModel *>(model) ||
+         qobject_cast<const FlexiNoteModel *>(model));
+    return does;
+}
+
+bool
 AudioGenerator::usesContinuousSynth(const Model *model)
 {
     bool cont = 
@@ -209,7 +221,8 @@
 
     QString clipPath = QString("%1/%2.wav").arg(m_sampleDir).arg(clipId);
 
-    if (!mixer->loadClipData(clipPath, clipF0)) {
+    float level = wantsQuieterClips(model) ? 0.5 : 1.0;
+    if (!mixer->loadClipData(clipPath, clipF0, level)) {
         delete mixer;
         return 0;
     }
@@ -551,7 +564,7 @@
             on.pan = pan;
 
 #ifdef DEBUG_AUDIO_GENERATOR
-	    cout << "mixModel [clip]: adding note at frame " << noteFrame << ", frame offset " << on.frameOffset << " frequency " << on.frequency << endl;
+	    cout << "mixModel [clip]: adding note at frame " << noteFrame << ", frame offset " << on.frameOffset << " frequency " << on.frequency << ", level " << on.level << endl;
 #endif
 	    
             starts.push_back(on);
--- a/audioio/AudioGenerator.h	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/AudioGenerator.h	Wed May 14 09:58:27 2014 +0100
@@ -135,6 +135,7 @@
     ContinuousSynthMap m_continuousSynthMap;
 
     bool usesClipMixer(const Model *);
+    bool wantsQuieterClips(const Model *);
     bool usesContinuousSynth(const Model *);
 
     ClipMixer *makeClipMixerFor(const Model *model);
--- a/audioio/ClipMixer.cpp	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/ClipMixer.cpp	Wed May 14 09:58:27 2014 +0100
@@ -40,7 +40,7 @@
 }
 
 bool
-ClipMixer::loadClipData(QString path, float f0)
+ClipMixer::loadClipData(QString path, float f0, float level)
 {
     if (m_clipData) {
         cerr << "ClipMixer::loadClipData: Already have clip loaded" << endl;
@@ -81,7 +81,7 @@
 	int j;
 	m_clipData[i] = 0.0f;
 	for (j = 0; j < info.channels; ++j) {
-	    m_clipData[i] += tmpFrames[i * info.channels + j];
+	    m_clipData[i] += tmpFrames[i * info.channels + j] * level;
 	}
     }
 
@@ -135,7 +135,7 @@
     foreach (NoteStart note, m_playing) {
 
         for (int c = 0; c < m_channels; ++c) {
-            levels[c] = gain;
+            levels[c] = note.level * gain;
         }
         if (note.pan != 0.0 && m_channels == 2) {
             levels[0] *= 1.0 - note.pan;
--- a/audioio/ClipMixer.h	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/ClipMixer.h	Wed May 14 09:58:27 2014 +0100
@@ -36,9 +36,12 @@
 
     /**
      * Load a sample clip from a wav file. This can only happen once:
-     * construct a new ClipMixer if you want a different clip.
+     * construct a new ClipMixer if you want a different clip. The
+     * clip was recorded at a pitch with fundamental frequency clipF0,
+     * and should be scaled by level (in the range 0-1) when playing
+     * back.
      */
-    bool loadClipData(QString clipFilePath, float clipF0);
+    bool loadClipData(QString clipFilePath, float clipF0, float level);
 
     void reset(); // discarding any playing notes
 
--- a/audioio/PlaySpeedRangeMapper.cpp	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/PlaySpeedRangeMapper.cpp	Wed May 14 09:58:27 2014 +0100
@@ -34,6 +34,13 @@
 }
 
 int
+PlaySpeedRangeMapper::getPositionForValueUnclamped(float value) const
+{
+    // We don't really provide this
+    return getPositionForValue(value);
+}
+
+int
 PlaySpeedRangeMapper::getPositionForFactor(float factor) const
 {
     bool slow = (factor > 1.0);
@@ -65,6 +72,13 @@
 }
 
 float
+PlaySpeedRangeMapper::getValueForPositionUnclamped(int position) const
+{
+    // We don't really provide this
+    return getValueForPosition(position);
+}
+
+float
 PlaySpeedRangeMapper::getValueForFactor(float factor) const
 {
     float pc;
--- a/audioio/PlaySpeedRangeMapper.h	Thu Apr 03 08:51:30 2014 +0100
+++ b/audioio/PlaySpeedRangeMapper.h	Wed May 14 09:58:27 2014 +0100
@@ -24,7 +24,10 @@
     PlaySpeedRangeMapper(int minpos, int maxpos);
 
     virtual int getPositionForValue(float value) const;
+    virtual int getPositionForValueUnclamped(float value) const;
+
     virtual float getValueForPosition(int position) const;
+    virtual float getValueForPositionUnclamped(int position) const;
 
     int getPositionForFactor(float factor) const;
     float getValueForFactor(float factor) const;
--- a/framework/MainWindowBase.cpp	Thu Apr 03 08:51:30 2014 +0100
+++ b/framework/MainWindowBase.cpp	Wed May 14 09:58:27 2014 +0100
@@ -134,7 +134,6 @@
 #endif
 
 MainWindowBase::MainWindowBase(bool withAudioOutput,
-                               bool withOSCSupport,
                                bool withMIDIInput) :
     m_document(0),
     m_paneStack(0),
@@ -255,12 +254,6 @@
     if (withMIDIInput) {
         m_midiInput = new MIDIInput(QApplication::applicationName(), this);
     }
-
-    if (withOSCSupport) {
-        m_oscQueueStarter = new OSCQueueStarter(this);
-        connect(m_oscQueueStarter, SIGNAL(finished()), this, SLOT(oscReady()));
-        m_oscQueueStarter->start();
-    }
 }
 
 MainWindowBase::~MainWindowBase()
@@ -271,6 +264,7 @@
     delete m_playSource;
     delete m_viewManager;
     delete m_oscQueue;
+    delete m_oscQueueStarter;
     delete m_midiInput;
     Profiles::getInstance()->dump();
 }
@@ -286,6 +280,14 @@
 }
 
 void
+MainWindowBase::startOSCQueue()
+{
+    m_oscQueueStarter = new OSCQueueStarter(this);
+    connect(m_oscQueueStarter, SIGNAL(finished()), this, SLOT(oscReady()));
+    m_oscQueueStarter->start();
+}
+
+void
 MainWindowBase::oscReady()
 {
     if (m_oscQueue && m_oscQueue->isOK()) {
--- a/framework/MainWindowBase.h	Thu Apr 03 08:51:30 2014 +0100
+++ b/framework/MainWindowBase.h	Wed May 14 09:58:27 2014 +0100
@@ -75,7 +75,7 @@
     Q_OBJECT
 
 public:
-    MainWindowBase(bool withAudioOutput, bool withOSCSupport, bool withMIDIInput);
+    MainWindowBase(bool withAudioOutput, bool withMIDIInput);
     virtual ~MainWindowBase();
     
     enum AudioFileOpenMode {
@@ -311,6 +311,7 @@
 
     OSCQueue                *m_oscQueue;
     OSCQueueStarter         *m_oscQueueStarter;
+    void startOSCQueue();
 
     MIDIInput               *m_midiInput;