Skip to content

Commit

Permalink
Wavemode7 (#457)
Browse files Browse the repository at this point in the history
* test all wavemodes
* fix wavemode=7 DoubleLine

* don't install test presets

* and don't create test directory

Co-authored-by: Matthew Bellew <matthewb@labkey.com>
  • Loading branch information
mbellew and labkey-matthewb committed Feb 14, 2021
1 parent 202741f commit 5ff6b4a
Show file tree
Hide file tree
Showing 11 changed files with 195 additions and 59 deletions.
4 changes: 2 additions & 2 deletions Makefile.am
Expand Up @@ -18,8 +18,8 @@ pm_font__DATA = fonts/Vera.ttf fonts/VeraMono.ttf

# find and install all preset files
install-data-local:
find "$(PRESETSDIR)" -type d -exec $(MKDIR_P) "$(DESTDIR)/$(pm_data_dir)/{}" \;
find "$(PRESETSDIR)" -type f -exec $(INSTALL_DATA) "{}" "$(DESTDIR)/$(pm_data_dir)/{}" \;
find "$(PRESETSDIR)" -path "$(PRESETSDIR)/tests" -prune -o -type d -exec $(MKDIR_P) "$(DESTDIR)/$(pm_data_dir)/{}" \;
find "$(PRESETSDIR)" -path "$(PRESETSDIR)/tests" -prune -o -type f -exec $(INSTALL_DATA) "{}" "$(DESTDIR)/$(pm_data_dir)/{}" \;

# from https://stackoverflow.com/questions/30897170/ac-subst-does-not-expand-variable answer: https://stackoverflow.com/a/30960268
# ptomato https://stackoverflow.com/users/172999/ptomato
Expand Down
4 changes: 2 additions & 2 deletions presets/tests/200-wave.milk
@@ -1,6 +1,6 @@
[preset00]
per_frame_1000=// simple wave to build
per_frame_1001=//
per_frame_1000=// simple wave
per_frame_1001=// MODE=0 Circle

fDecay=0.980000
nWaveMode=0
Expand Down
20 changes: 20 additions & 0 deletions presets/tests/201-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=1

fDecay=0.980000
nWaveMode=1
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/202-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=2 Blob2

fDecay=0.980000
nWaveMode=2
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/203-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=3 Blob3

fDecay=0.980000
nWaveMode=3
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/204-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=4 DerivativeLine

fDecay=0.980000
nWaveMode=4
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/205-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=5 Blob5

fDecay=0.980000
nWaveMode=5
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/206-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=6 Line

fDecay=0.980000
nWaveMode=6
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
20 changes: 20 additions & 0 deletions presets/tests/207-wave.milk
@@ -0,0 +1,20 @@
[preset00]
per_frame_1000=// simple wave
per_frame_1001=// MODE=7 DoubleLine

fDecay=0.980000
nWaveMode=7
bMaximizeWaveColor=1
fWaveAlpha=4.400000
fWaveScale=1.605447
fZoomExponent=1.000000
zoom=1.000000
rot=0.006000
warp=0.000000
sx=1.000000
sy=1.000000
wave_r=0.900000
wave_g=0.90000
wave_b=0.900000
wave_x=0.500000
wave_y=0.500000
File renamed without changes.
106 changes: 51 additions & 55 deletions src/libprojectM/Renderer/MilkdropWaveform.cpp
Expand Up @@ -42,85 +42,76 @@ void MilkdropWaveform::Draw(RenderContext &context)
if (samples > (int)PCM::maxsamples)
samples = (int)PCM::maxsamples;

WaveformMath(context);
WaveformMath(context);

glBindBuffer(GL_ARRAY_BUFFER, m_vboID);
for (int waveno=1 ; waveno<=(two_waves?2:1) ; waveno++)
{
glBindBuffer(GL_ARRAY_BUFFER, m_vboID);

glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, wavearray, GL_DYNAMIC_DRAW);

if (two_waves) {
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, wavearray2, GL_DYNAMIC_DRAW);
}
if (waveno == 1)
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, wavearray, GL_DYNAMIC_DRAW);
else
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * samples * 2, wavearray2, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glUseProgram(context.programID_v2f_c4f);
glUseProgram(context.programID_v2f_c4f);

glm::mat4 mat_first_translation = glm::mat4(1.0);
mat_first_translation[3][0] = -0.5;
mat_first_translation[3][1] = -0.5;
glm::mat4 mat_first_translation = glm::mat4(1.0);
mat_first_translation[3][0] = -0.5;
mat_first_translation[3][1] = -0.5;

glm::mat4 mat_scale = glm::mat4(1.0);
mat_scale[0][0] = aspectScale;
glm::mat4 mat_scale = glm::mat4(1.0);
mat_scale[0][0] = aspectScale;

float s = glm::sin(glm::radians(-rot));
float c = glm::cos(glm::radians(-rot));
glm::mat4 mat_rotation = glm::mat4( c,-s, 0, 0,
s, c, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
float s = glm::sin(glm::radians(-rot));
float c = glm::cos(glm::radians(-rot));
glm::mat4 mat_rotation = glm::mat4(c, -s, 0, 0,
s, c, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);

glm::mat4 mat_second_translation = glm::mat4(1.0);
mat_second_translation[3][0] = 0.5;
mat_second_translation[3][1] = 0.5;
glm::mat4 mat_second_translation = glm::mat4(1.0);
mat_second_translation[3][0] = 0.5;
mat_second_translation[3][1] = 0.5;

glm::mat4 mat_vertex = context.mat_ortho;
mat_vertex = mat_first_translation * mat_vertex;
mat_vertex = mat_scale * mat_vertex;
mat_vertex = mat_rotation * mat_vertex;
mat_vertex = mat_second_translation * mat_vertex;
glUniformMatrix4fv(context.uniform_v2f_c4f_vertex_tranformation, 1, GL_FALSE, glm::value_ptr(mat_vertex));
glm::mat4 mat_vertex = context.mat_ortho;
mat_vertex = mat_first_translation * mat_vertex;
mat_vertex = mat_scale * mat_vertex;
mat_vertex = mat_rotation * mat_vertex;
mat_vertex = mat_second_translation * mat_vertex;
glUniformMatrix4fv(context.uniform_v2f_c4f_vertex_tranformation, 1, GL_FALSE, glm::value_ptr(mat_vertex));

if(modulateAlphaByVolume) ModulateOpacityByVolume(context);
else temp_a = a;
MaximizeColors(context);
if (modulateAlphaByVolume) ModulateOpacityByVolume(context);
else temp_a = a;
MaximizeColors(context);

#ifndef GL_TRANSITION
if(dots==1) glEnable(GL_LINE_STIPPLE);
if (dots == 1) glEnable(GL_LINE_STIPPLE);
#endif

//Thick wave drawing
if (thick==1) glLineWidth( (context.texsize < 512 ) ? 2 : 2*context.texsize/512);
else glLineWidth( (context.texsize < 512 ) ? 1 : context.texsize/512);

//Additive wave drawing (vice overwrite)
if (additive==1)glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBindVertexArray(m_vaoID);
//Thick wave drawing
if (thick == 1) glLineWidth((context.texsize < 512) ? 2 : 2 * context.texsize / 512);
else glLineWidth((context.texsize < 512) ? 1 : context.texsize / 512);

if (loop)
glDrawArrays(GL_LINE_LOOP,0,samples);
else
glDrawArrays(GL_LINE_STRIP,0,samples);
//Additive wave drawing (vice overwrite)
if (additive == 1)glBlendFunc(GL_SRC_ALPHA, GL_ONE);
else glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glBindVertexArray(m_vaoID);

if (two_waves)
{
if (loop)
glDrawArrays(GL_LINE_LOOP,0,samples);
glDrawArrays(GL_LINE_LOOP, 0, samples);
else
glDrawArrays(GL_LINE_STRIP,0,samples);
}
glDrawArrays(GL_LINE_STRIP, 0, samples);

glBindVertexArray(0);
glBindVertexArray(0);
}

#ifndef GL_TRANSITION
if(dots==1) glDisable(GL_LINE_STIPPLE);
#endif

}

void MilkdropWaveform::ModulateOpacityByVolume(RenderContext &context)
Expand Down Expand Up @@ -228,6 +219,8 @@ void MilkdropWaveform::WaveformMath(RenderContext &context)
rot = 0;
aspectScale=1.0;

samples = context.beatDetect->pcm->numsamples;

float inv_nverts_minus_one = 1.0f/(float)(samples);

float last_value = vol_scale * (pcmdataR[samples-1]+pcmdataL[samples-1]);
Expand Down Expand Up @@ -347,8 +340,9 @@ void MilkdropWaveform::WaveformMath(RenderContext &context)
rot = -mystery*90;
aspectScale =1.0f+wave_x_temp;
wave_x_temp=-1*(x-1.0f);
samples = context.beatDetect->pcm->numsamples;

for ( int i=0; i< samples;i++)
for ( int i=0; i<samples; i++)
{
wavearray[i][0]=i/(float) samples;
wavearray[i][1]=vol_scale*pcmdataR[i]*.04f*scale+wave_x_temp;
Expand All @@ -365,6 +359,8 @@ void MilkdropWaveform::WaveformMath(RenderContext &context)
rot = -mystery*90;
aspectScale =1.0f+wave_x_temp;


samples = context.beatDetect->pcm->numsamples;
two_waves = true;

const float y_adj = y*y*.5f;
Expand Down

0 comments on commit 5ff6b4a

Please sign in to comment.