Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working on Implementation of Panning #1061

Merged
merged 28 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5703755
Note & Instr. Pan interaction
oddtime Jan 3, 2021
c908c32
pan laws as static member functions of Sampler
oddtime Jan 3, 2021
83db742
add descriptive comments, make getRatioPan() obligatory, avoid the mu…
oddtime Jan 10, 2021
617ffd3
added other pan law functions
oddtime Jan 10, 2021
f847974
select pan Law from preferences
oddtime Jan 10, 2021
60574be
added 3 linear weighted pan laws
oddtime Jan 10, 2021
e977d81
save pan law as integer index in .h2song
oddtime Jan 10, 2021
90bd8a5
added 3 polar pan laws
oddtime Jan 10, 2021
f164f78
add constant k norm pan law
oddtime Jan 10, 2021
6e5cfbc
better manage of GUI pan Law combobox items, add 3 quadratic pan laws
oddtime Jan 11, 2021
cf4f147
add 3 constant Norm pan laws, commented unused method
oddtime Jan 11, 2021
19329e7
translatable, further descriptive comments
oddtime Jan 11, 2021
c7dd952
pan law members moved to Sampler, pan law enum class, save in song as…
oddtime Jan 18, 2021
f1cf556
add PanLawDialog, remove from PreferencesDialog
oddtime Jan 18, 2021
093bb6a
deprecate pointers to pan law static member function
oddtime Jan 18, 2021
7ecf62b
mixerSetting button in mixer master line
oddtime Jan 19, 2021
f606a60
correct and clean
oddtime Jan 19, 2021
2655e93
correct and clean 2
oddtime Jan 19, 2021
dad1cc0
merge master
oddtime Jan 19, 2021
99ae760
sharper icon
oddtime Jan 20, 2021
5089fab
add tooltip in pan law combo box
oddtime Jan 20, 2021
98813cd
headings in pan law combobox
oddtime Jan 23, 2021
9b5a79b
merge master
oddtime Jan 23, 2021
e799a46
typo
oddtime Jan 23, 2021
dc21783
mantainabilty changes
oddtime Jan 28, 2021
07c7afc
a line was missed
oddtime Jan 28, 2021
bface81
changelog, some graphic in doc comments
oddtime Jan 30, 2021
11bb83f
replace test.ref.flac because the new pan law functions introduce neg…
oddtime Feb 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/core/Basics/Song.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <core/Helpers/Xml.h>
#include <core/Helpers/Filesystem.h>
#include <core/Hydrogen.h>
#include <core/Sampler/Sampler.h>

#ifdef H2CORE_HAVE_OSC
#include <core/NsmClient.h>
Expand Down Expand Up @@ -86,6 +87,7 @@ Song::Song( const QString& name, const QString& author, float bpm, float volume
, __playback_track_enabled( false )
, __playback_track_volume( 0.0 )
, __velocity_automation_path( nullptr )
, m_nPanLawIdx( RATIO_STRAIGHT_POLYGONAL )
{
INFOLOG( QString( "INIT '%1'" ).arg( __name ) );

Expand Down
15 changes: 15 additions & 0 deletions src/core/Basics/Song.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ class Song : public H2Core::Object
*/
bool has_missing_samples();
void clear_missing_samples();

void setPanLawIdx( int idx );
int getPanLawIdx() const ;

private:
///< volume of the song (0.0..1.0)
Expand Down Expand Up @@ -265,8 +268,12 @@ class Song : public H2Core::Object
AutomationPath* __velocity_automation_path;
///< license of the song
QString __license;
/** this is set in preferences
*/
int m_nPanLawIdx;
};


inline bool Song::get_is_modified() const
{
return __is_modified;
Expand Down Expand Up @@ -419,6 +426,14 @@ inline void Song::set_playback_track_volume( const float volume )
__playback_track_volume = volume;
}

inline void Song::setPanLawIdx( int idx ) {
m_nPanLawIdx = idx;
}

inline int Song::getPanLawIdx() const {
return m_nPanLawIdx;
}

/**
\ingroup H2CORE
\brief Read XML file of a song
Expand Down
20 changes: 17 additions & 3 deletions src/core/Sampler/Sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ float Sampler::getRatioPan( float fPan_L, float fPan_R ) {
* has 0 dB center compensation.
*/

float Sampler::ratioConstantSumPanLaw( float fPan ) {
float Sampler::ratioConstSumPanLaw( float fPan ) {
// the constant Sum pan law interpreting fPan as the "ratio" parameter
if ( fPan <= 0 ) {
return 1. / (2. + fPan );
Expand All @@ -301,7 +301,7 @@ float Sampler::ratioConstantSumPanLaw( float fPan ) {
}
}

float Sampler::ratioConstantPowerPanLaw( float fPan ) {
float Sampler::ratioConstPowerPanLaw( float fPan ) {
// the constant power pan law interpreting fPan as the "ratio" parameter
if ( fPan <= 0 ) {
return 1. / sqrt( 1 + ( 1. + fPan ) * ( 1. + fPan ) );
Expand Down Expand Up @@ -372,7 +372,8 @@ bool Sampler::renderNote( Note* pNote, unsigned nBufferSize, Song* pSong )
// use Straight pol pan law.
// TODO a new song member, set in preferences, must point the desired pan law Sampler member function
float (*panLaw)( float );
panLaw = &this->ratioStraightPolygonalPanLaw;
panLaw = getPanLawAddress( pSong->getPanLawIdx() );
//panLaw = &this->ratioStraightPolygonalPanLaw;
float fPan_L = panLaw( fPan );
float fPan_R = panLaw( -fPan );
//---------------------------------------------------------
Expand Down Expand Up @@ -1544,5 +1545,18 @@ void Sampler::reinitializePlaybackTrack()
m_nPlayBackSamplePosition = 0;
}

inline float ( *Sampler::getPanLawAddress( int idx ) ) ( float ) {
if ( idx == RATIO_STRAIGHT_POLYGONAL ) {
return &ratioStraightPolygonalPanLaw;
} else if ( idx == RATIO_CONST_POWER ) {
return &ratioConstPowerPanLaw;
} else if ( idx == RATIO_CONST_SUM ) {
return &ratioConstSumPanLaw;
} else {
//TODO warning
return &ratioStraightPolygonalPanLaw; // default value
}
}

};

12 changes: 10 additions & 2 deletions src/core/Sampler/Sampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
#include <vector>
#include <memory>

// NOTE: the following value must be respected by the indices in GUI preferences combo box!!!
#define RATIO_STRAIGHT_POLYGONAL 0
#define RATIO_CONST_POWER 1
#define RATIO_CONST_SUM 2

namespace H2Core
{

Expand Down Expand Up @@ -111,9 +116,11 @@ class Sampler : public H2Core::Object

// functions for pan law
static float getRatioPan( float fPan_L, float fPan_R );
oddtime marked this conversation as resolved.
Show resolved Hide resolved
static float ratioConstantSumPanLaw( float fPan );
static float ratioConstantPowerPanLaw( float fPan );
static float ratioStraightPolygonalPanLaw( float fPan );
static float ratioConstPowerPanLaw( float fPan );
static float ratioConstSumPanLaw( float fPan );

float ( *getPanLawAddress( int idx ) ) ( float );

private:
std::vector<Note*> m_playingNotesQueue;
Expand Down Expand Up @@ -175,6 +182,7 @@ class Sampler : public H2Core::Object
);
};


} // namespace

#endif
Expand Down
7 changes: 7 additions & 0 deletions src/gui/src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ PreferencesDialog::PreferencesDialog(QWidget* parent)

resampleComboBox->setCurrentIndex( (int) AudioEngine::get_instance()->get_sampler()->getInterpolateMode() );

Song* pSong = Hydrogen::get_instance()->getSong();
panLawComboBox->setCurrentIndex( pSong->getPanLawIdx() );

// Appearance tab
QString applicationFamily = pPref->getApplicationFontFamily();
int applicationPointSize = pPref->getApplicationFontPointSize();
Expand Down Expand Up @@ -478,6 +481,10 @@ void PreferencesDialog::on_okBtn_clicked()
else if ( sampleRateComboBox->currentText() == "96000" ) {
pPref->m_nSampleRate = 96000;
}

Song* pSong = Hydrogen::get_instance()->getSong();
pSong->setPanLawIdx( panLawComboBox->currentIndex() );



// metronome
Expand Down
106 changes: 66 additions & 40 deletions src/gui/src/PreferencesDialog_UI.ui
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_1">
<attribute name="title">
Expand Down Expand Up @@ -384,45 +384,45 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="jackBBTSyncLbl">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="text">
<string>BBT sync method</string>
</property>
<property name="toolTip">
<string>Specifies the variable, which has to remain constant in order to guarantee a working synchronization and relocation in the presence of another Jack timebase master.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="jackBBTSyncComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Specifies the variable, which has to remain constant in order to guarantee a working synchronization and relocation in the presence of another Jack timebase master.</string>
</property>
<item>
<property name="text">
<string>constant measure</string>
</property>
</item>
<item>
<property name="text">
<string>matching bars</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="jackBBTSyncLbl">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Specifies the variable, which has to remain constant in order to guarantee a working synchronization and relocation in the presence of another Jack timebase master.</string>
oddtime marked this conversation as resolved.
Show resolved Hide resolved
</property>
<property name="text">
<string>BBT sync method</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="jackBBTSyncComboBox">
<property name="minimumSize">
<size>
<width>0</width>
<height>22</height>
</size>
</property>
<property name="toolTip">
<string>Specifies the variable, which has to remain constant in order to guarantee a working synchronization and relocation in the presence of another Jack timebase master.</string>
oddtime marked this conversation as resolved.
Show resolved Hide resolved
</property>
<item>
<property name="text">
<string>constant measure</string>
</property>
</item>
<item>
<property name="text">
<string>matching bars</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
Expand Down Expand Up @@ -564,6 +564,32 @@
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="panLawLbl">
<property name="text">
<string>Pan Law</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="panLawComboBox">
<item>
<property name="text">
<string>Balance Law (0 compensation)</string>
</property>
</item>
<item>
<property name="text">
<string>Costant Power</string>
oddtime marked this conversation as resolved.
Show resolved Hide resolved
</property>
</item>
<item>
<property name="text">
<string>Constant Sum</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
Expand Down