Skip to content

Commit

Permalink
正确使用C++ const
Browse files Browse the repository at this point in the history
  • Loading branch information
satgo1546 committed Aug 5, 2017
1 parent 6aba220 commit 53d57a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions VLib/VMath.hpp
Expand Up @@ -39,9 +39,9 @@ namespace Math {
return value[i];
}
};
// 然后就实例化一个实例出来
#define VMATH_SINE_TABLE_SIZE ((size_t) 256)
const SineTable<float, VMATH_SINE_TABLE_SIZE> sine_table;
// 然后就实例化唯一的一个实例出来
const size_t SINE_TABLE_SIZE = 256;
const SineTable<float, SINE_TABLE_SIZE> sine_table;
//-------------------------------------------------------------------------
// ● clamp
//-------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions VMDE/Audio/channel_sine.cpp
Expand Up @@ -13,7 +13,7 @@ namespace Audio {
//-------------------------------------------------------------------------
Channel_Sine::Channel_Sine(float freq) {
index = .0f;
index_delta = VMATH_SINE_TABLE_SIZE / ((float) AUDIO_SAMPLE_RATE / 4 / freq);
index_delta = V::Math::SINE_TABLE_SIZE / ((float) AUDIO_SAMPLE_RATE / 4 / freq);
minus = false;
}
//-------------------------------------------------------------------------
Expand All @@ -31,8 +31,8 @@ namespace Audio {
//-------------------------------------------------------------------------
float Channel_Sine::next() {
index += index_delta;
if (index >= (float) VMATH_SINE_TABLE_SIZE) {
index = VMATH_SINE_TABLE_SIZE * 2.0f - index;
if (index >= (float) V::Math::SINE_TABLE_SIZE) {
index = V::Math::SINE_TABLE_SIZE * 2.0f - index;
index_delta = -index_delta;
} else if (index < 0) {
index = -index;
Expand Down

0 comments on commit 53d57a8

Please sign in to comment.