Skip to content

Commit

Permalink
correlate shadertoy audio of user supplied audio data
Browse files Browse the repository at this point in the history
  • Loading branch information
nir committed Apr 27, 2021
1 parent 849b681 commit 538bf84
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jupylet/shadertoy.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@ def get_correlation(a0, size=300, step=2, prev=[]):
return ix


def get_shadertoy_audio(amp=1., length=512, buffer=500, data=None, channel_time=None):
def get_shadertoy_audio(
amp=1.,
length=512,
buffer=500,
data=None,
channel_time=None,
correlate=True,
):

if data is not None:
a0 = data
Expand All @@ -100,9 +107,10 @@ def get_shadertoy_audio(amp=1., length=512, buffer=500, data=None, channel_time=

if a0 is None:
a0 = np.zeros((length, 2))
else:
ix = get_correlation(a0.mean(-1), buffer)
a0 = a0[ix:][:length]

if correlate:
ix = get_correlation(a0.mean(-1), buffer)
a0 = a0[ix:][:length]

if channel_time is not None:
ct = channel_time
Expand Down

0 comments on commit 538bf84

Please sign in to comment.