Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wavemode7 #457

Merged
merged 4 commits into from
Feb 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile.am
Original file line number Diff line number Diff line change
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)/{}" \;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that the test presets get copied when you do "make install". This skips the tests directory. Hmm, should probably do that on the line above as well...

As always opinions/testing appreciated!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: I followed the link on this page to install winamp/milkdrop2. http://www.geisswerks.com/milkdrop/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm ok I'm not an advanced find user - I guess that's doing two different things in one statement? wild


# 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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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