Skip to content

Commit e1d11ba

Browse files
authored
Merge pull request #10 from lukemcraig/code-style
Code style
2 parents 6295035 + 73b9f4f commit e1d11ba

24 files changed

+213
-187
lines changed

OvertoneFilter.jucer

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
</VS2019>
8787
<XCODE_MAC targetFolder="Builds/MacOSX">
8888
<CONFIGURATIONS>
89-
<CONFIGURATION isDebug="1" name="Debug"/>
90-
<CONFIGURATION isDebug="0" name="Release"/>
89+
<CONFIGURATION isDebug="1" name="Debug" osxCompatibility="10.10 SDK"/>
90+
<CONFIGURATION isDebug="0" name="Release" osxCompatibility="10.10 SDK"/>
9191
</CONFIGURATIONS>
9292
<MODULEPATHS>
9393
<MODULEPATH id="juce_video" path="../../juce"/>

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ Simulate *sygyt* style overtone singing (a.k.a. throat singing) by emphasizing M
33

44
[Audio examples](https://soundcloud.com/lukemcraig/sets/ovetone-filter-audio-examples)
55

6-
![screenshot](https://github.com/lukemcraig/OvertoneFilter/raw/master/screenshot.png)
6+
![screenshot](https://github.com/lukemcraig/OvertoneFilter/raw/master/screenshot.png)
7+
8+
The following GIF shows a spectrogram of the signal before and after processing. Notice that the melody in the second frame is created only from the harmonics in the original signal.
9+
10+
![spectrogram](https://github.com/lukemcraig/OvertoneFilter/raw/master/spectrogram.gif)
11+
12+
[Here is a YouTube video showing the plug-in operating:](https://youtu.be/OiNwpGFCm-0)
13+
14+
<a href="https://youtu.be/OiNwpGFCm-0" target="_blank"><img src="https://i9.ytimg.com/vi/OiNwpGFCm-0/maxresdefault.jpg" alt="Overtone Filter Video" border="10" /></a>

Source/Attributes.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ Attributes::Attributes(OpenGLContext& openGLContext, OpenGLShaderProgram& shader
1616
position.reset(createAttribute(openGLContext, shaderProgram, "position"));
1717
}
1818

19-
void Attributes::enable(OpenGLContext& glContext)
19+
void Attributes::enable(OpenGLContext& glContext) const
2020
{
21-
if (position.get() != nullptr)
21+
if (position != nullptr)
2222
{
2323
glContext.extensions.glVertexAttribPointer(position->attributeID, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex),
2424
nullptr);
2525
glContext.extensions.glEnableVertexAttribArray(position->attributeID);
2626
}
2727
}
2828

29-
void Attributes::disable(OpenGLContext& glContext)
29+
void Attributes::disable(OpenGLContext& glContext) const
3030
{
31-
if (position.get() != nullptr) glContext.extensions.glDisableVertexAttribArray(position->attributeID);
31+
if (position != nullptr) glContext.extensions.glDisableVertexAttribArray(position->attributeID);
3232
}
3333

3434
OpenGLShaderProgram::Attribute* Attributes::createAttribute(

Source/Attributes.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ struct Attributes
1616
{
1717
Attributes(OpenGLContext& openGLContext, OpenGLShaderProgram& shaderProgram);
1818

19-
void enable(OpenGLContext& glContext);
19+
void enable(OpenGLContext& glContext) const;
2020

21-
void disable(OpenGLContext& glContext);
21+
void disable(OpenGLContext& glContext) const;
2222

2323
std::unique_ptr<OpenGLShaderProgram::Attribute> position;
2424

Source/LevelMeter.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
LevelMeter.cpp
55
Created: 2 Oct 2019 3:52:35pm
6-
Author: Luke
6+
Author: Luke McDuffie Craig
77
88
==============================================================================
99
*/
@@ -24,15 +24,15 @@ LevelMeter::~LevelMeter()
2424

2525
void LevelMeter::paint(Graphics& g)
2626
{
27-
auto lineCol = getLookAndFeel().findColour(MidiKeyboardComponent::keySeparatorLineColourId);
27+
const auto lineCol = getLookAndFeel().findColour(MidiKeyboardComponent::keySeparatorLineColourId);
2828
auto area = getLocalBounds();
29-
g.setColour(lineCol);
29+
g.setColour(lineCol);
3030
g.drawRect(area);
3131
area.reduce(2, 2);
3232
g.setColour(Colour(0xffB28859));
3333
g.drawRect(area);
3434
area.reduce(2, 2);
35-
g.setColour(lineCol);
35+
g.setColour(lineCol);
3636
g.drawRect(area);
3737
area.reduce(2, 2);
3838
g.setColour(Colour(0xffB28859));
@@ -58,15 +58,14 @@ void LevelMeter::shutdown()
5858
uniforms.reset();
5959
}
6060

61-
void LevelMeter::renderScene()
61+
void LevelMeter::renderScene() const
6262
{
63-
//render scene
64-
auto desktopScale = (float)openGLContext.getRenderingScale();
65-
auto width = roundToInt(desktopScale * getWidth());
66-
auto height = roundToInt(desktopScale * getHeight());
63+
const auto desktopScale = static_cast<float>(openGLContext.getRenderingScale());
64+
const auto width = roundToInt(desktopScale * static_cast<float>(getWidth()));
65+
const auto height = roundToInt(desktopScale * static_cast<float>(getHeight()));
6766

68-
auto x = getRight() * desktopScale - width;
69-
auto y = (getParentHeight() - getBottom()) * desktopScale;
67+
const auto x = static_cast<float>(getRight()) * desktopScale - width;
68+
const auto y = static_cast<float>(getParentHeight() - getBottom()) * desktopScale;
7069
glViewport(x, y, width, height);
7170

7271
shaderProgram->use();
@@ -91,7 +90,7 @@ void LevelMeter::renderScene()
9190
quad->draw(openGLContext, *attributes);
9291
}
9392

94-
void LevelMeter::render()
93+
void LevelMeter::render() const
9594
{
9695
jassert(OpenGLHelpers::isContextActive());
9796

@@ -146,7 +145,7 @@ void LevelMeter::createShaders()
146145
attributes.reset();
147146
uniforms.reset();
148147

149-
shaderProgram.reset(newShader.release());
148+
shaderProgram = std::move(newShader);
150149
shaderProgram->use();
151150

152151
attributes.reset(new Attributes(openGLContext, *shaderProgram));
@@ -158,7 +157,7 @@ void LevelMeter::createShaders()
158157
}
159158
}
160159

161-
void LevelMeter::renderOpenGL()
160+
void LevelMeter::renderOpenGL() const
162161
{
163162
render();
164163
}

Source/LevelMeter.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
LevelMeter.h
55
Created: 2 Oct 2019 3:52:35pm
6-
Author: Luke
6+
Author: Luke McDuffie Craig
77
88
==============================================================================
99
*/
@@ -33,13 +33,13 @@ class LevelMeter : public Component
3333

3434
void shutdown();
3535

36-
void renderScene();
36+
void renderScene() const;
3737

38-
void render();
38+
void render() const;
3939

4040
void createShaders();
4141

42-
void renderOpenGL();
42+
void renderOpenGL() const;
4343

4444
//==============================================================================
4545

Source/LevelMeterAudioSource.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
LevelMeterAudioSource.cpp
55
Created: 4 Oct 2019 11:05:10am
6-
Author: Luke
6+
Author: Luke McDuffie Craig
77
88
==============================================================================
99
*/
@@ -18,24 +18,22 @@ LevelMeterAudioSource::~LevelMeterAudioSource()
1818
{
1919
}
2020

21-
void LevelMeterAudioSource::prepare(float timeConstant, float sampleRate)
21+
void LevelMeterAudioSource::prepare(const float timeConstant, const float sampleRate)
2222
{
2323
alpha = std::exp(-1.0f / (timeConstant * sampleRate));
2424
yPrevious = 0.0f;
2525
prepared = true;
2626
}
2727

28-
void LevelMeterAudioSource::pushSample(float sample)
28+
void LevelMeterAudioSource::pushSample(const float sample)
2929
{
3030
jassert(prepared);
31-
yPrevious = alpha * yPrevious + (1.0f - alpha) * (sample*sample);
31+
yPrevious = alpha * yPrevious + (1.0f - alpha) * (sample * sample);
3232
}
3333

3434
float LevelMeterAudioSource::getLevel() const
3535
{
36-
if(prepared)
36+
if (prepared)
3737
return std::sqrt(yPrevious);
38-
else{
39-
return 0.0f;
40-
}
38+
return 0.0f;
4139
}

Source/LevelMeterAudioSource.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
LevelMeterAudioSource.h
55
Created: 4 Oct 2019 11:05:10am
6-
Author: Luke
6+
Author: Luke McDuffie Craig
77
88
==============================================================================
99
*/

Source/MyMidiKeyboardComponent.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313

1414
//==============================================================================
1515
MyMidiKeyboardComponent::MyMidiKeyboardComponent(OvertoneFilterAudioProcessor& p, MidiKeyboardState& state,
16-
Orientation orientation, ParameterHelper& ph) :
16+
const Orientation orientation, ParameterHelper& ph) :
1717
MidiKeyboardComponent(state, orientation),
1818
processor(p), parameterHelper(ph)
1919
{
20+
jassert(orientation==horizontalKeyboard);
2021
setColour(whiteNoteColourId, Colours::white);
2122
setColour(blackNoteColourId, Colour(0xffB28859));
2223
setColour(mouseOverKeyOverlayColourId, Colours::grey);
@@ -37,7 +38,7 @@ void MyMidiKeyboardComponent::paint(Graphics& g)
3738
g.drawRoundedRectangle(getLocalBounds().toFloat(), 5.0f, 5.0f);
3839
}
3940

40-
void MyMidiKeyboardComponent::parameterChanged(const String& parameterID, float newValue)
41+
void MyMidiKeyboardComponent::parameterChanged(const String& parameterID, float /*newValue*/)
4142
{
4243
if (parameterID == parameterHelper.pidPitchStandard)
4344
{
@@ -66,20 +67,21 @@ void MyMidiKeyboardComponent::mouseUp(const MouseEvent& e)
6667
}
6768

6869
//==============================================================================
69-
bool MyMidiKeyboardComponent::mouseDraggedToKey(int midiNoteNumber, const MouseEvent& e)
70+
bool MyMidiKeyboardComponent::mouseDraggedToKey(int /*midiNoteNumber*/, const MouseEvent& /*e*/)
7071
{
7172
return false;
7273
}
7374

74-
bool MyMidiKeyboardComponent::mouseDownOnKey(int midiNoteNumber, const MouseEvent& e)
75+
bool MyMidiKeyboardComponent::mouseDownOnKey(const int midiNoteNumber, const MouseEvent& /*e*/)
7576
{
7677
currentNoteDown = midiNoteNumber;
7778
processor.handleNoteOn(static_cast<float>(midiNoteNumber));
7879
return false;
7980
}
8081

81-
void MyMidiKeyboardComponent::drawWhiteNote(int midiNoteNumber, Graphics& g, const Rectangle<float> area,
82-
bool isDown, bool isOver, Colour lineColour, Colour textColour)
82+
void MyMidiKeyboardComponent::drawWhiteNote(const int midiNoteNumber, Graphics& g, const Rectangle<float> area,
83+
const bool isDown, const bool isOver, const Colour lineColour,
84+
const Colour textColour)
8385
{
8486
auto c = Colours::transparentWhite;
8587

@@ -93,13 +95,14 @@ void MyMidiKeyboardComponent::drawWhiteNote(int midiNoteNumber, Graphics& g, con
9395

9496
if (text.isNotEmpty())
9597
{
96-
const auto freq = parameterHelper.getCurrentPitchStandard(0) * std::pow(2.0f, (midiNoteNumber - 69.0f) / 12.0f);
97-
const auto freqText = String(freq, 1) + ((midiNoteNumber==0) ? " Hz" : "");
98+
const auto freq = parameterHelper.getCurrentPitchStandard(0) * std::pow(
99+
2.0f, (static_cast<float>(midiNoteNumber) - 69.0f) / 12.0f);
100+
const auto freqText = String(freq, 1) + (midiNoteNumber == 0 ? " Hz" : "");
98101

99102
const auto fontHeight = getKeyWidth();
100103
const Font freqFont(fontHeight * .7f);
101104
auto area2 = area;
102-
const auto areaToDraw = area2.removeFromBottom(freqFont.getStringWidth(freqText) +6.0f).withTrimmedBottom(6.0f);
105+
const auto areaToDraw = area2.removeFromBottom(freqFont.getStringWidth(freqText) + 6).withTrimmedBottom(6);
103106

104107
g.setColour(textColour);
105108
g.setFont(freqFont);
@@ -124,8 +127,9 @@ void MyMidiKeyboardComponent::drawWhiteNote(int midiNoteNumber, Graphics& g, con
124127
}
125128
}
126129

127-
void MyMidiKeyboardComponent::drawBlackNote(int midiNoteNumber, Graphics& g, Rectangle<float> area, bool isDown,
128-
bool isOver, Colour noteFillColour)
130+
void MyMidiKeyboardComponent::drawBlackNote(int /*midiNoteNumber*/, Graphics& g, Rectangle<float> area,
131+
const bool isDown,
132+
const bool isOver, const Colour noteFillColour)
129133
{
130134
auto c = noteFillColour;
131135

0 commit comments

Comments
 (0)