Skip to content

Commit 356baab

Browse files
authored
Made it possible for smoothPresetDuration, presetDurtion, and hardCutDuration (#488)
to be Double precision numbers instead of /as well as integers. This will allow more complex transitions, such as transitions on measure detect or 4 beat detects for example. Forsing this to generte youtube videos, it would be good for the transitions to happen precisely when measures or stances in the music change.
1 parent f9cfdfe commit 356baab

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/libprojectM/TimeKeeper.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class TimeKeeper
4242

4343
void ChangeHardcutDuration(int seconds) { _hardcutDuration = seconds; }
4444
void ChangePresetDuration(int seconds) { _presetDuration = seconds; }
45+
void ChangeHardcutDuration(double seconds) { _hardcutDuration = seconds; }
46+
void ChangePresetDuration(double seconds) { _presetDuration = seconds; }
4547

4648
#ifndef WIN32
4749
/* The first ticks value of the application */

src/libprojectM/projectM.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ void projectM::readConfig (const std::string & configFile)
175175
_settings.fps = config.read<int> ( "FPS", 35 );
176176
_settings.windowWidth = config.read<int> ( "Window Width", 512 );
177177
_settings.windowHeight = config.read<int> ( "Window Height", 512 );
178-
_settings.smoothPresetDuration = config.read<int>
178+
_settings.smoothPresetDuration = config.read<double>
179179
( "Smooth Preset Duration", config.read<int>("Smooth Transition Duration", 10));
180-
_settings.presetDuration = config.read<int> ( "Preset Duration", 15 );
180+
_settings.presetDuration = config.read<double> ( "Preset Duration", 15 );
181181

182182
#ifdef __unix__
183183
_settings.presetURL = config.read<string> ( "Preset Path", "/usr/local/share/projectM/presets" );
@@ -223,7 +223,7 @@ void projectM::readConfig (const std::string & configFile)
223223
// Hard Cuts are preset transitions that occur when your music becomes louder. They only occur after a hard cut duration threshold has passed.
224224
_settings.hardcutEnabled = config.read<bool> ( "Hard Cuts Enabled", false );
225225
// Hard Cut duration is the number of seconds before you become eligible for a hard cut.
226-
_settings.hardcutDuration = config.read<int> ( "Hard Cut Duration", 60 );
226+
_settings.hardcutDuration = config.read<double> ( "Hard Cut Duration", 60 );
227227
// Hard Cut sensitivity is the volume difference before a "hard cut" is triggered.
228228
_settings.hardcutSensitivity = config.read<float> ( "Hard Cut Sensitivity", 1.0 );
229229

@@ -1116,12 +1116,20 @@ void projectM::changeTextureSize(int size) {
11161116
_settings.titleFontURL, _settings.menuFontURL,
11171117
_settings.datadir);
11181118
}
1119+
11191120
void projectM::changeHardcutDuration(int seconds) {
11201121
timeKeeper->ChangeHardcutDuration(seconds);
11211122
}
11221123
void projectM::changePresetDuration(int seconds) {
11231124
timeKeeper->ChangePresetDuration(seconds);
11241125
}
1126+
1127+
void projectM::changeHardcutDuration(double seconds) {
1128+
timeKeeper->ChangeHardcutDuration(seconds);
1129+
}
1130+
void projectM::changePresetDuration(double seconds) {
1131+
timeKeeper->ChangePresetDuration(seconds);
1132+
}
11251133
void projectM::getMeshSize(int *w, int *h) {
11261134
*w = _settings.meshX;
11271135
*h = _settings.meshY;

src/libprojectM/projectM.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ class DLLEXPORT projectM
133133
std::string titleFontURL;
134134
std::string menuFontURL;
135135
std::string datadir;
136-
int smoothPresetDuration;
137-
int presetDuration;
136+
double smoothPresetDuration;
137+
double presetDuration;
138138
bool hardcutEnabled;
139139
int hardcutDuration;
140140
float hardcutSensitivity;
@@ -151,8 +151,8 @@ class DLLEXPORT projectM
151151
textureSize(512),
152152
windowWidth(512),
153153
windowHeight(512),
154-
smoothPresetDuration(10),
155-
presetDuration(15),
154+
smoothPresetDuration(10.0),
155+
presetDuration(15.0),
156156
hardcutEnabled(false),
157157
hardcutDuration(60),
158158
hardcutSensitivity(2.0),
@@ -181,7 +181,9 @@ class DLLEXPORT projectM
181181

182182
void changeTextureSize(int size);
183183
void changeHardcutDuration(int seconds);
184+
void changeHardcutDuration(double seconds);
184185
void changePresetDuration(int seconds);
186+
void changePresetDuration(double seconds);
185187
void getMeshSize(int *w, int *h);
186188
void touch(float x, float y, int pressure, int touchtype);
187189
void touchDrag(float x, float y, int pressure);

0 commit comments

Comments
 (0)