Skip to content

Commit

Permalink
Compile Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Dec 7, 2024
1 parent 81af0e5 commit 7aac18f
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/AudioTools/CoreAudio/AudioBasic/Int24_3bytes_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class int24_3bytes_t {
} // namespace audio_tools

#ifdef USE_TYPETRAITS
#include <limits>

namespace std {
template<> class numeric_limits<audio_tools::int24_3bytes_t> {
Expand Down
1 change: 1 addition & 0 deletions src/AudioTools/CoreAudio/AudioBasic/Int24_4bytes_t.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class int24_4bytes_t {
} // namespace audio_tools

#ifdef USE_TYPETRAITS
#include <limits>

namespace std {
template<> class numeric_limits<audio_tools::int24_4bytes_t> {
Expand Down
22 changes: 11 additions & 11 deletions src/AudioTools/CoreAudio/AudioEffects/AudioEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,20 @@ class Delay : public AudioEffect {

void setDepth(float value) {
depth = value;
if (depth > 1.0)
depth = 1.0;
if (depth < 0)
depth = 0.0;
if (depth > 1.0f)
depth = 1.0f;
if (depth < 0.0f)
depth = 0.0f;
}

float getDepth() { return depth; }

void setFeedback(float feed) {
feedback = feed;
if (feedback > 1.0)
feedback = 1.0;
if (feedback < 0)
feedback = 0.0;
if (feedback > 1.0f)
feedback = 1.0f;
if (feedback < 0.0f)
feedback = 0.0f;
}

float getFeedback() { return feedback; }
Expand All @@ -306,7 +306,7 @@ class Delay : public AudioEffect {
int32_t delayed_value = buffer[delay_line_index];

// Mix the above with current audio and write the results back to output
int32_t out = ((1.0 - depth) * input) + (depth * delayed_value);
int32_t out = ((1.0f - depth) * input) + (depth * delayed_value);

// Update each delay line
buffer[delay_line_index] = clip(feedback * (delayed_value + input));
Expand All @@ -322,7 +322,7 @@ class Delay : public AudioEffect {

protected:
Vector<effect_t> buffer{0};
float feedback = 0.0, duration = 0.0, sampleRate = 0.0, depth = 0.0;
float feedback = 0.0f, duration = 0.0f, sampleRate = 0.0f, depth = 0.0f;
size_t delay_len_samples = 0;
size_t delay_line_index = 0;

Expand Down Expand Up @@ -510,7 +510,7 @@ class Compressor : public AudioEffect {

/// Defines the compression ratio from 0 to 1
void setCompressionRatio(float compressionRatio){
if (compressionRatio<1.0){
if (compressionRatio < 1.0f){
gainreduce = compressionRatio;
}
recalculate();
Expand Down
6 changes: 3 additions & 3 deletions src/AudioTools/CoreAudio/AudioEffects/PitchShift.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ template <typename T> class VariableSpeedRingBuffer : public BaseBuffer<T> {
}

T read() {
assert(read_increment != 0.0);
assert(read_increment != 0.0f);
T result = peek();
read_pos_float += read_increment;
handleReadWriteOverrun(last_value);
Expand Down Expand Up @@ -283,8 +283,8 @@ template <typename T> class VariableSpeedRingBuffer : public BaseBuffer<T> {
protected:
Vector<T> buffer{0};
int buffer_size;
float read_pos_float = 0.0;
float read_increment = 0.0;
float read_pos_float = 0.0f;
float read_increment = 0.0f;
int write_pos = 0;
// used to handle overruns:
T last_value = 0; // record last read value
Expand Down
6 changes: 3 additions & 3 deletions src/AudioTools/CoreAudio/AudioEffects/SoundGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ template <class T> class SineWaveGenerator : public SoundGenerator<T> {
float m_amplitude = 1.0f;
float m_deltaTime = 0.0f;
float m_phase = 0.0f;
const float double_Pi = PI * 2.0f;
const float double_Pi = 2.0f * PI;

void logStatus() {
SoundGenerator<T>::info.logStatus();
Expand Down Expand Up @@ -243,8 +243,8 @@ template <class T> class FastSineGenerator : public SineWaveGenerator<T> {
T result = SineWaveGenerator<T>::m_amplitude * sine(angle);
SineWaveGenerator<T>::m_cycles +=
SineWaveGenerator<T>::m_frequency * SineWaveGenerator<T>::m_deltaTime;
if (SineWaveGenerator<T>::m_cycles > 1.0) {
SineWaveGenerator<T>::m_cycles -= 1.0;
if (SineWaveGenerator<T>::m_cycles > 1.0f) {
SineWaveGenerator<T>::m_cycles -= 1.0f;
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/CoreAudio/AudioIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TransformationReader {

// we read half the necessary bytes
if (buffer.size() == 0) {
int size = (0.5 / p_transform->getByteFactor() * len);
int size = (0.5f / p_transform->getByteFactor() * len);
// process full samples/frames
size = size / 4 * 4;
LOGI("read size: %d", size);
Expand Down
4 changes: 2 additions & 2 deletions src/AudioTools/CoreAudio/Buffers.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ class BaseBuffer {
/// Returns the level of the buffer in %
virtual float levelPercent() {
// prevent div by 0.
if (size()==0) return 0.0;
return 100.0 * static_cast<float>(available()) / static_cast<float>(size());
if (size()==0) return 0.0f;
return 100.0f * static_cast<float>(available()) / static_cast<float>(size());
}

protected:
Expand Down
8 changes: 4 additions & 4 deletions src/AudioTools/CoreAudio/MusicalNotes.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ class MusicalNotes {

/// Determine frequency of MIDI note
float midiNoteToFrequency(int x) const {
float a = 440; //frequency of A (coomon value is 440Hz)
return (a / 32) * pow(2, ((x - 9) / 12.0f));
float a = 440.0f; //frequency of A (coomon value is 440Hz)
return (a / 32.0f) * powf(2.0f, ((x - 9) / 12.0f));
}

/// Provide MIDI note for frequency
int frequencyToMidiNote(float freq) const {
return log(freq/440.0f)/log(2) * 12.0f + 69.0f;
return logf(freq/440.0f)/logf(2) * 12.0f + 69.0f;
}

float stkNoteToFrequency(int noteNumber) const {
return 220.0f * pow( 2.0f, (noteNumber - 57.0f) / 12.0f );
return 220.0f * powf( 2.0f, (noteNumber - 57.0f) / 12.0f );
}

protected:
Expand Down
4 changes: 2 additions & 2 deletions src/AudioTools/CoreAudio/ResampleStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ class ResampleStream : public ReformatBaseStream {
}
}

float getByteFactor() { return 1.0 / step_size; }
float getByteFactor() { return 1.0f / step_size; }

protected:
Vector<uint8_t> last_samples{0};
Expand All @@ -221,7 +221,7 @@ class ResampleStream : public ReformatBaseStream {
size_t write(Print *p_out, const uint8_t *buffer, size_t bytes,
size_t &written) {
this->p_out = p_out;
if (step_size == 1.0) {
if (step_size == 1.0f) {
written = p_out->write(buffer, bytes);
return written;
}
Expand Down
15 changes: 7 additions & 8 deletions src/AudioTools/CoreAudio/VolumeControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ class CachedVolumeControl : public VolumeControl {
/// determines a multiplication factor (0.0 to 1.0) from an input value (0.0 to 1.0).
virtual float getVolumeFactor(float volume) {
if (p_vc==nullptr) return 1.0f; // prevent NPE
if (abs(volume-in)<0.01f){
if (fabs(volume-in)<0.01f){
return out;
} else {
in = volume;
out = p_vc->getVolumeFactor(volume);
return out;
}
}
in = volume;
out = p_vc->getVolumeFactor(volume);
return out;
}

protected:
Expand All @@ -86,9 +85,9 @@ class LogarithmicVolumeControl : public VolumeControl {

// provides a factor in the range of 0.0 to 1.0
virtual float getVolumeFactor(float input) {
float b = pow(((1/ym)-1), 2);
float b = powf(((1/ym)-1), 2);
float a = 1.0f / (b - 1.0f);
float volumeFactor = pow(b,input) * a - a;
float volumeFactor = powf(b,input) * a - a;
return limit(volumeFactor);
}

Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/CoreAudio/VolumeStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class VolumeStream : public ModifyingStream, public VolumeSupport {

/// Sets the volume for one channel
bool setVolume(float vol, int channel){
if ((vol > 1.0 && !info.allow_boost) || vol < 0) {
if ((vol > 1.0f && !info.allow_boost) || vol < 0.0f) {
LOGE("Invalid volume: %f", vol);
return false;
}
Expand Down

0 comments on commit 7aac18f

Please sign in to comment.