aboutsummaryrefslogtreecommitdiff
path: root/audio/stretchplayer/fine_tuning.diff
blob: 10aa30e43010b25563f3f50df081e1af93651d03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
diff -Naur stretchplayer-0.503/src/Engine.cpp stretchplayer-0.503.patched/src/Engine.cpp
--- stretchplayer-0.503/src/Engine.cpp	2010-07-18 00:44:20.000000000 -0400
+++ stretchplayer-0.503.patched/src/Engine.cpp	2014-02-28 17:43:36.000000000 -0500
@@ -46,6 +46,7 @@
 	  _sample_rate(48000.0),
 	  _stretch(1.0),
 	  _pitch(0),
+	  _fine(0),
 	  _gain(1.0)
     {
 	QString err;
@@ -153,7 +154,7 @@
 	uint32_t srate = _audio_system->sample_rate();
 
 	_stretcher->setTimeRatio( srate / _sample_rate / _stretch );
-	_stretcher->setPitchScale( ::pow(2.0, double(_pitch)/12.0) * _sample_rate / srate );
+	_stretcher->setPitchScale( ::pow(2.0, double(_pitch)/12.0 + double(_fine)/1200.0) * _sample_rate / srate );
 
 	uint32_t frame;
 	uint32_t reqd, gend, zeros, feed;
diff -Naur stretchplayer-0.503/src/Engine.hpp stretchplayer-0.503.patched/src/Engine.hpp
--- stretchplayer-0.503/src/Engine.hpp	2010-07-18 00:44:20.000000000 -0400
+++ stretchplayer-0.503.patched/src/Engine.hpp	2014-03-01 11:26:57.000000000 -0500
@@ -81,6 +81,21 @@
 	//_state_changed = true;
     }
 
+    int get_fine() {
+	return _fine;
+    }
+    void set_fine(int fin) {
+	if(fin < -99) {
+	    _fine = fin % 100;
+		 set_pitch(get_pitch() - 1);
+	} else if (fin > 99) {
+	    _fine = fin % 100;
+		 set_pitch(get_pitch() + 1);
+	} else {
+	    _fine = fin;
+	}
+    }
+
     /**
      * Clipped to [0.0, 10.0]
      */
@@ -146,6 +161,7 @@
     float _sample_rate;
     float _stretch;
     int _pitch;
+    int _fine;
     float _gain;
     std::auto_ptr<RubberBand::RubberBandStretcher> _stretcher;
     std::auto_ptr<AudioSystem> _audio_system;
diff -Naur stretchplayer-0.503/src/PlayerWidget.cpp stretchplayer-0.503.patched/src/PlayerWidget.cpp
--- stretchplayer-0.503/src/PlayerWidget.cpp	2010-07-18 00:44:20.000000000 -0400
+++ stretchplayer-0.503.patched/src/PlayerWidget.cpp	2014-03-01 10:04:02.000000000 -0500
@@ -35,6 +35,7 @@
 #include <QBitmap>
 #include <QAction>
 #include <QResizeEvent>
+#include <QApplication>
 #include <QCoreApplication>
 
 #include <cmath>
@@ -152,11 +153,21 @@
 
     void PlayerWidget::pitch_inc()
     {
+		 if(QApplication::keyboardModifiers() == Qt::ShiftModifier)
+	_engine->set_fine( _engine->get_fine() + 10);
+		 else if(QApplication::keyboardModifiers() == Qt::ControlModifier)
+	_engine->set_fine( _engine->get_fine() + 1);
+		 else
 	_engine->set_pitch( _engine->get_pitch() + 1 );
     }
 
     void PlayerWidget::pitch_dec()
     {
+		 if(QApplication::keyboardModifiers() == Qt::ShiftModifier)
+	_engine->set_fine( _engine->get_fine() - 10);
+		 else if(QApplication::keyboardModifiers() == Qt::ControlModifier)
+	_engine->set_fine( _engine->get_fine() - 1);
+		 else
 	_engine->set_pitch( _engine->get_pitch() - 1);
     }
 
@@ -262,8 +273,9 @@
 	float sch = _engine->get_stretch();
 	_status->speed(sch);
 
+	int fin = _engine->get_fine();
 	int pit = _engine->get_pitch();
-	_status->pitch(pit);
+	_status->pitch(pit, fin);
 
 	float cpu = _engine->get_cpu_load();
 	_status->cpu(cpu);
@@ -471,8 +483,9 @@
 	QList<QKeySequence> inc_shortcuts;
 	inc_shortcuts << Qt::Key_Plus;
 	inc_shortcuts << Qt::Key_Equal;
+	inc_shortcuts << QKeySequence("Ctrl+=");
 	_act.pitch_inc = new QAction("+", this);
-	_act.pitch_inc->setToolTip("Pitch Increase [+]");
+	_act.pitch_inc->setToolTip("Pitch Increase [+ or =] (Ctl/Shift=Fine)");
 	_act.pitch_inc->setShortcuts(inc_shortcuts);
 	_act.pitch_inc->setShortcutContext(Qt::ApplicationShortcut);
 	_act.pitch_inc->setIcon( _ico.plus );
@@ -480,9 +493,13 @@
 	connect(_act.pitch_inc, SIGNAL(triggered()),
 		this, SLOT(pitch_inc()));
 
+	QList<QKeySequence> dec_shortcuts;
+	dec_shortcuts << Qt::Key_Minus;
+	dec_shortcuts << Qt::Key_Underscore;
+	dec_shortcuts << QKeySequence("Ctrl+-");
 	_act.pitch_dec = new QAction("-", this);
-	_act.pitch_dec->setToolTip("Pitch Decrease [-]");
-	_act.pitch_dec->setShortcut(Qt::Key_Minus);
+	_act.pitch_dec->setToolTip("Pitch Decrease [-] (Ctl/Shift=Fine)");
+	_act.pitch_dec->setShortcuts(dec_shortcuts);
 	_act.pitch_dec->setShortcutContext(Qt::ApplicationShortcut);
 	_act.pitch_dec->setIcon( _ico.minus );
 	addAction(_act.pitch_dec);
diff -Naur stretchplayer-0.503/src/StatusWidget.cpp stretchplayer-0.503.patched/src/StatusWidget.cpp
--- stretchplayer-0.503/src/StatusWidget.cpp	2010-07-18 00:44:20.000000000 -0400
+++ stretchplayer-0.503.patched/src/StatusWidget.cpp	2014-03-01 11:16:47.000000000 -0500
@@ -85,10 +85,13 @@
 	    .arg(val, 3, 'f', 0);
     }
 
-    void StatusWidget::pitch(int p)
+    void StatusWidget::pitch(int p, int f)
     {
-	_pitch = QString("PITCH: %1")
-	    .arg(int(p));
+	_pitch = QString("PITCH: %1").arg(int(p));
+		if(f > 0)
+			_pitch += QString("+%1").arg(int(f));
+		else if(f < 0)
+			_pitch += QString("%1").arg(int(f));
     }
 
     void StatusWidget::volume(float g)
diff -Naur stretchplayer-0.503/src/StatusWidget.hpp stretchplayer-0.503.patched/src/StatusWidget.hpp
--- stretchplayer-0.503/src/StatusWidget.hpp	2010-07-18 00:44:20.000000000 -0400
+++ stretchplayer-0.503.patched/src/StatusWidget.hpp	2014-02-28 19:20:49.000000000 -0500
@@ -54,7 +54,7 @@
     void position(float);
     void time(float);
     void speed(float);
-    void pitch(int);
+    void pitch(int, int);
     void volume(float);
     void cpu(float);
     void message(QString);