diff --git a/src/Music.ts b/src/Music.ts index e2b9284..382aef2 100644 --- a/src/Music.ts +++ b/src/Music.ts @@ -1,14 +1,14 @@ import { GLCat, GLCatBuffer, GLCatProgram, GLCatTexture, GLCatTransformFeedback } from '@fms-cat/glcat-ts'; -import { MUSIC_BPM, MUSIC_BUFFER_LENGTH } from './config'; +import { MUSIC_AUTOMATON_TEXTURE_HEIGHT, MUSIC_BPM, MUSIC_BUFFER_LENGTH } from './config'; import { Pool } from './utils/Pool'; import musicVert from './shaders/music.vert'; import { gl, glCat } from './globals/canvas'; import samplesOpus from './samples.opus'; import { randomTextureStatic } from './globals/randomTexture'; -import { auto, automaton } from './globals/automaton'; +import { automaton } from './globals/automaton'; import { Channel } from '@fms-cat/automaton'; import { injectCodeToShader } from './utils/injectCodeToShader'; -import { AutomatonWithGUI } from '@fms-cat/automaton-with-gui'; +import type { AutomatonWithGUI } from '@fms-cat/automaton-with-gui'; const discardFrag = '#version 300 es\nvoid main(){discard;}'; @@ -31,6 +31,7 @@ export class Music { private __samples?: GLCatTexture; private __automatonChannelList: Channel[]; private __automatonDefineString: string; + private __arrayAutomaton: Float32Array; private __textureAutomaton: GLCatTexture; constructor( glCat: GLCat, audio: AudioContext ) { @@ -51,12 +52,12 @@ export class Music { this.__bufferTransformFeedbacks[ 0 ].setVertexbuffer( MUSIC_BUFFER_LENGTH * 4, - gl.DYNAMIC_COPY + gl.STREAM_READ ); this.__bufferTransformFeedbacks[ 1 ].setVertexbuffer( MUSIC_BUFFER_LENGTH * 4, - gl.DYNAMIC_COPY + gl.STREAM_READ ); this.__transformFeedback.bindBuffer( 0, this.__bufferTransformFeedbacks[ 0 ] ); @@ -68,6 +69,10 @@ export class Music { this.__updateAutomatonChannelList(); + this.__arrayAutomaton = new Float32Array( + MUSIC_BUFFER_LENGTH * MUSIC_AUTOMATON_TEXTURE_HEIGHT + ); + this.__textureAutomaton = glCat.createTexture(); this.__textureAutomaton.textureFilter( gl.NEAREST ); @@ -210,26 +215,25 @@ export class Music { if ( channelName.startsWith( 'Music/' ) ) { const key = channelName.substring( 6 ); const index = this.__automatonChannelList.length; - this.__automatonDefineString += `const int AUTO_${key}=${index};`; + const y = ( index + 0.5 ) / MUSIC_AUTOMATON_TEXTURE_HEIGHT; + this.__automatonDefineString += `const float AUTO_${key}=${y};`; this.__automatonChannelList.push( channel ); } } } private __updateAutomatonTexture(): void { - const buffer = new Float32Array( MUSIC_BUFFER_LENGTH * 256 ); - for ( const [ iChannel, channel ] of this.__automatonChannelList.entries() ) { for ( let iSample = 0; iSample < MUSIC_BUFFER_LENGTH; iSample ++ ) { const t = this.time + iSample / this.audio.sampleRate; - buffer[ MUSIC_BUFFER_LENGTH * iChannel + iSample ] = channel.getValue( t ); + this.__arrayAutomaton[ MUSIC_BUFFER_LENGTH * iChannel + iSample ] = channel.getValue( t ); } } this.__textureAutomaton.setTextureFromArray( MUSIC_BUFFER_LENGTH, - 256, - buffer, + MUSIC_AUTOMATON_TEXTURE_HEIGHT, + this.__arrayAutomaton, { internalformat: gl.R32F, format: gl.RED, diff --git a/src/automaton-fxs/automatonFxs.ts b/src/automaton-fxs/automatonFxs.ts index e6223f8..f775ffd 100644 --- a/src/automaton-fxs/automatonFxs.ts +++ b/src/automaton-fxs/automatonFxs.ts @@ -1 +1,3 @@ export { sine, hermitePatch } from '@fms-cat/automaton-fxs'; +export { repeat } from './repeat'; +export { transpose } from './transpose'; diff --git a/src/automaton-fxs/repeat.ts b/src/automaton-fxs/repeat.ts new file mode 100644 index 0000000..b37e701 --- /dev/null +++ b/src/automaton-fxs/repeat.ts @@ -0,0 +1,22 @@ +import type { FxDefinition } from '@fms-cat/automaton'; + +export const repeat: FxDefinition = { + name: 'Repeat', + description: 'Repeat a section of the curve.', + params: { + interval: { name: 'Interval', type: 'float', default: 1.0, min: 0.0 }, + }, + func( context ) { + if ( context.index === context.i1 ) { + context.setShouldNotInterpolate( true ); + } + + if ( + ( context.elapsed + context.deltaTime ) % context.params.interval < context.deltaTime + ) { + context.setShouldNotInterpolate( true ); + } + + return context.getValue( context.t0 + context.elapsed % context.params.interval ); + } +}; diff --git a/src/automaton-fxs/transpose.ts b/src/automaton-fxs/transpose.ts new file mode 100644 index 0000000..3eac9f9 --- /dev/null +++ b/src/automaton-fxs/transpose.ts @@ -0,0 +1,19 @@ +import type { FxDefinition } from '@fms-cat/automaton'; + +export const transpose: FxDefinition = { + params: { + note: { name: 'Note', type: 'float', default: 0.0 } + }, + func( context ) { + if ( context.init ) { + context.state.v0 = context.value; + } + + if ( context.index === context.i1 ) { + context.setShouldNotInterpolate( true ); + } + + const { v0 } = context.state; + return v0 + ( context.value - v0 ) * Math.pow( 2.0, context.params.note / 12.0 ); + } +}; diff --git a/src/automaton.json b/src/automaton.json index 9d547a7..1e33aac 100644 --- a/src/automaton.json +++ b/src/automaton.json @@ -1 +1 @@ -{"version":"4.1.1","resolution":100,"curves":[{"nodes":[[0,1,0,0,0.16140350877192983],[1,0,-0.47719298245614045]]},{"nodes":[[0,0,0,0,0.1],[0.3747555183012014,1,-0.1,0,0.1],[1.3333333333333333,0,-0.1]]},{"nodes":[[],[0.6666666666666666,1,-0.4560629631300563,-0.1852941176470587]]},{"nodes":[[0,0,0,0,0.2355866843161978],[1.3333333333333333,1.2000000000000002,-0.1]]},{"nodes":[[0,0,0,0,0.12284595300261082,0.061764705882352944],[0.6666666666666666,0.4,-0.1]]},{"nodes":[[0,0,0,0,0.10333333333333335],[1,1]]},{"nodes":[[0,0,0,0,0.1],[0.3333333333333333,1,-0.1,0,0.1],[0.6666666666666666,0,-0.1]]},{"nodes":[[0,0,0,0,0.12284595300261095,1.0980392156862744],[1.3333333333333333,0.8,-0.1]]},{"nodes":[[0,0,0,0,0.016158102050275177,0.4803921568627448],[0.02868275456174794,1,-0.017181893944471203,0.046509328639327226,0.07352361117377113,-0.1990196078431371],[0.25,0,-0.025439765782812148,0.6242474227849143]]},{"nodes":[[],[0.5,0.5,0,0,0.3072250626170559,0.32683448369273865],[1.3333333333333333,1.5]]},{"nodes":[[0,0.2,0,0,0.18674781789871728,2.609799325705191],[0.6666666666666666,0.1,-0.3546547911950566,0.44607843137254866]]},{"nodes":[[0,0.15115889256979576,0,0,0.1],[1.3333333333333333,0.7344636184844164,-0.8192982456140352,-0.01372549019607843]],"fxs":[{"def":"sine","params":{"amp":0.42000000000000004,"freq":9.43,"offset":0},"time":0.5833333333333333,"length":0.75},{"def":"hermitePatch","params":{},"time":0.5,"length":0.16666666666666663,"row":1}]}],"channels":[["Glitch/amp",{"items":[{},{"time":10.666666666666666,"length":1,"curve":0},{"time":256}]}],["PixelSorter/amp",{"items":[{},{"time":15.666666666666666,"length":1.666666666666666,"curve":1}]}],["Music/NEURO_TIME",{"items":[{"time":42.666666666666664,"length":0.6666666666666643,"curve":2},{"time":43.33333333333333,"length":1.3333333333333357,"curve":3},{"time":44.666666666666664,"length":0.6666666666666643,"curve":5,"speed":2.280000000000004,"amp":0.5},{"time":46,"length":1.3333333333333286,"curve":9,"speed":1.0000000000000109},{"time":48,"length":0.6666666666666643,"curve":2,"speed":0.6666666666666642}]}],["Music/NEURO_DETUNE",{"items":[{"time":42.666666666666664,"length":0.6666666666666643,"curve":4},{"time":43.33333333333333,"length":1.3333333333333357,"value":0.050000000000000024},{"time":44.666666666666664,"length":0.6666666666666643,"value":0.08000000000000045},{"time":46,"length":1.3333333333333286,"value":0.40000000000000024},{"time":47.33333333333333,"length":0.6666666666666643,"curve":10,"amp":0.15588235294117658},{"time":48,"length":0.6666666666666643,"value":1.0431372549019606,"curve":4}]}],["Music/NEURO_DETUNE_PHASE",{"items":[{"time":42.666666666666664,"length":0.6666666666666643,"value":1},{"time":43.33333333333333,"length":1.3333333333333357,"value":0.0299999999999997},{"time":44.666666666666664,"length":0.6666666666666643,"value":0.19000000000000006},{"time":46,"length":1.3333333333333286,"value":1},{"time":48,"length":0.6666666666666643,"value":0.0399999999999995}]}],["Music/NEURO_WUB_AMP",{"items":[{"time":42.664755294969126,"length":0.6685780383642026,"curve":6},{"time":43.33333333333333,"length":1.3333333333333357,"curve":7},{"time":44.666666666666664,"length":0.25,"curve":8},{"time":44.916666666666664,"length":0.25,"curve":8},{"time":45.166666666666664,"length":0.1666666666666643,"curve":8},{"time":46,"length":1.3333333333333286,"curve":11},{"time":48,"length":0.6685780383642026,"curve":6}]}],["Music/NEURO_WUB_FREQ",{"items":[{"time":42.666666666666664,"length":0.6666666666666643,"value":1},{"time":43.33333333333333,"length":1.3333333333333357,"value":1},{"time":44.666666666666664,"length":0.6666666666666643,"value":0.5},{"time":46,"length":1.3333333333333286,"value":2},{"time":48,"length":0.6666666666666643,"value":1}]}]],"labels":{"zero":0},"guiSettings":{"snapTimeActive":true,"snapTimeInterval":0.1,"snapValueActive":true,"snapValueInterval":0.1,"snapBeatActive":true,"bpm":180,"beatOffset":0,"useBeatInGUI":true,"minimizedPrecisionTime":3,"minimizedPrecisionValue":3}} \ No newline at end of file +{"version":"4.1.1","resolution":100,"curves":[{"nodes":[[0,1,0,0,0.16140350877192983],[1,0,-0.47719298245614045]]},{"nodes":[[0,0,0,0,0.1],[0.3747555183012014,1,-0.1,0,0.1],[1.3333333333333333,0,-0.1]]},{"nodes":[[],[0.6666666666666666,1,-0.4560629631300563,-0.1852941176470587],[0.6666666666666666,0,0,0,0.26644908616188,0.1029411764705882],[2,1.1900000000000002,-0.1],[2,0.00686274509803933,0,0,0.10652741514360319],[2.6666666666666665,0.7000000000000001],[2.6666666666666665,0,0,0,0.1391644908616188,0.5215686274509802],[3.333333333333333,0.9,-0.5014360313315928,-0.22647058823529403],[3.333333333333333,0,0,0,0.3974946346535474,0.10043744264185422],[4.666666666666666,1.2000000000000002,0,0,0.1],[4.666666666666666],[5.333333333333333,0.7000000000000001,-0.24079400848586707,-0.49736814906842436],[5.333333333333333],[6,0.8,-0.4356422056174482,-0.17156862745098037],[6,0,0,0,0.32852235276081576,0.05490196078431372],[7.333333333333333,1.1441176470588237,-0.1,0,0.1],[7.333333333333333],[8,0.3333],[8,0,0,0,0.08806743643105143,0.4254901960784307],[8.666666666666666,0.9,-0.3995834676293276,-0.08230605476940031],[8.666666666666666],[9.4,1.1,-0.2785205844025618,-0.17156862745098012,0.2785205844025618,0.17156862745098012],[10,1.3],[10],[10.666666666666666,0.6000000000000001,-0.11225401796276425,-0.5783350570563074]],"fxs":[{"def":"repeat","params":{"interval":0.2299999999999996},"time":7.333333333333333,"length":0.6666666666666667}]},{"nodes":[[0,0,0,0,0.12284595300261082,0.061764705882352944],[0.6666666666666666,0.4,-0.1],[0.6666666666666666,0.06568627450980391],[2,0.2],[2.236344893790143,0.4,-0.1,0,0.1],[2.6666666666666665,0,-0.34575086532310695,0,0.04271204452939744],[2.769918291305192,0.1,-0.05130523784998782,0,0.09999999999999999],[3.333333333333333,0.1],[3.6666666666666665,0.32774323388394533],[4.666666666666666,0.30000000000000004],[4.666666666666666,0.023323265139934546],[5.333333333333333,0.1],[5.333333333333333],[6,0.30000000000000004],[6,0.02745098039215696,0,0,0.09974597868276715,-0.006845312262542842],[7.333333333333333,0.1,-0.1],[7.333333333333333,0.7000000000000001],[8.666666666666666,0.7000000000000001],[8.666666666666666,1],[10,0.1],[10.666666666666666]]},{"nodes":[[0,0,0,0,0.1],[0.3333333333333333,1,-0.1,0,0.1],[0.6666666666666666,0,-0.1],[1.9166666666666665,1,-1.0007832898172324,0,0.06],[2],[2.025071712633245,1,-0.044516971279373374,0,0.1],[2.1623944411350506,0.5,-0.07221383357420871,0.2738348538091391,0.07221383357420871,-0.2738348538091391],[2.6666666666666665,0,-0.1,0,0.1],[3,1,-0.2864316909347707,0,0.24406085208595923],[3.333333333333333,0,-0.036443741726782705,0.4106336078810942],[3.6666666666666665,0.7544057184393509,-0.08631141286229893,-0.07178801363349067,0.13346814639852406,0.11100980502520727],[4.666666666666666,1,-0.33942558746736295,-0.018347344929083464,0.09208797505724492,-0.3264027483296351],[4.851079899134173,0.30000000000000004,-0.07486057061026631,-0.013179150760383026,0.1],[5.0444017511428605,0.9656862745098039,-0.1,0,0.1],[5.333333333333333,0.044689231228471016,-0.1,0,0.1],[5.666666666666666,1,-0.1,0,0.1],[6,0,-0.1],[7.333333333333333,1,-1.0426547051383652,0,0.1],[7.621393263296473,0.331783725954214,-0.1,0,0.1],[8,1],[8,0,-0.1,0,0.1],[8.166666666666666,1,-0.099988538641853,-0.006965859231865531],[8.489362746562259,1,0,0,0.09998887794379856,-0.006861981819672439],[8.666666666666666,0,-0.11262160793957762,0.041182622607896624],[8.9,1,-0.11617352813418727,-0.020588235294117612,0.11617352813418727,0.020588235294117612],[9.04400609908224,0.15784313725490162,-0.0988340957186134,-0.027450980392156817,0.0988340957186134,0.027450980392156817],[9.3,1,-0.09200304954112025,-0.041176470588235224,0.09200304954112025,0.041176470588235224],[9.5,0.2,-0.09449923761471994,-0.06176470588235285,0.09449923761471994,0.06176470588235285],[9.666666666666666,1,-0.08899847522943988,-0.027450980392156817,0.08899847522943988,0.027450980392156817],[10,0.30000000000000004,-0.06149466330303955,-0.06176470588235285,0.06149466330303955,0.06176470588235285],[10,1,-0.1,0,0.1],[10.666666666666666,0.1,-0.1,0,0.1]],"fxs":[{"def":"repeat","params":{"interval":0.2490000000000001},"time":2,"length":0.6666666666666665},{"def":"sine","params":{"amp":0.26,"freq":8.590000000000002,"offset":0},"time":3.934411837854859,"length":0.7322548288118069},{"def":"sine","params":{"amp":0.4400000000000004,"freq":5.889999999999998,"offset":0},"time":10.234266741175261,"length":0.4323999254914046},{"def":"hermitePatch","params":{},"time":3.821100533282267,"length":0.12610951070520438,"row":1},{"def":"hermitePatch","params":{},"time":10.18270758125172,"length":0.09198590579094379,"row":1}]},{"nodes":[[],[0.5,0.5,0,0,0.3072250626170559,0.32683448369273865],[1.3333333333333333,1.5]]},{"nodes":[[0,0.2,0,0,0.18674781789871728,2.609799325705191],[0.6666666666666666,0.1,-0.3546547911950566,0.44607843137254866]]},{"nodes":[[0,0.15115889256979576,0,0,0.1],[1.3333333333333333,0.7344636184844164,-0.8192982456140352,-0.01372549019607843]],"fxs":[{"def":"sine","params":{"amp":0.42000000000000004,"freq":9.43,"offset":0},"time":0.5833333333333333,"length":0.75},{"def":"hermitePatch","params":{},"time":0.5,"length":0.16666666666666663,"row":1}]},{"nodes":[[0,0,0,0,0.1],[0.6666666666666666,1,-0.1],[0.6666666666666666,0.04000000000000001],[2,0.019999999999999997],[2,0.4],[2.6666666666666665],[3.333333333333333,0.2,-0.1],[3.333333333333333,0.5],[4.666666666666666,0.6000000000000001],[4.666666666666666,0.059594068084455554],[5.333333333333333],[6,0.1],[7.333333333333333,0,-1.3219093627620064,-0.061764705882352944],[8],[8,0.8],[10,0.8],[10,0.1],[10.666666666666666]]},{"nodes":[[0,0,0,0,0.11631853785900784,0.15784313725490196],[0.3333333333333333,0.2,-0.1,-0.06862745098039215],[0.3333333333333333,0,0,0,0.10652741514360313,0.034313725490196074],[0.6257615317667536,0.4,-0.035197899213743125,-0.1178437887562426,0.05762038784328031,0.19291505927163513],[1.5833333333333333,1.6588235294117648,-0.14423846823324632,-0.08235294117647059],[1.5833333333333333,0,0,0,0.0706266318537859,0.12352941176470589],[1.8333333333333333,0.6000000000000001,-0.07923141560987097,-0.16655319476142408,0.05223508415950609,0.10980392156862741],[2,0.8,-0.07771415202426331,-0.04117647058823528]]},{"nodes":[[0,0.7000000000000001,0,0,0.14895561357702347,-0.7343137254901958],[0.6666666666666666,0.01999999999999999,-0.07958650842810296,0.0005266470222471706,0.7602446192333546,-0.005030759268204068],[2,0.2,-0.175065274151436,-0.0480392156862745]]},{"nodes":[[0,0.264705882352941,0,0,0.2664490861618798,-0.3705882352941175],[2,0,-0.1]]},{"nodes":[[0,0,0,0,0.1],[0.3333333333333333,0.9460784313725474,-0.1,0,0.1],[1.3333333333333333,0.3627450980392144,-0.11276290315437737,0.31798356313506776,0.058202350589290165,-0.16412659044332573],[1.6666666666666665,1,-0.1,0,0.1],[1.75,-0.5431372549019617,-0.1,0,0.1],[2,0,-0.07062663185378593,-0.25392156862745086]],"fxs":[{"def":"sine","params":{"amp":0.3999999999999999,"freq":17.779999999999987,"offset":0},"time":0.6103133159268926,"length":0.7230200174064406},{"def":"hermitePatch","params":{},"time":0.5580939947780674,"length":0.08289817232376029,"row":1},{"def":"hermitePatch","params":{},"time":1.2836814621409922,"length":0.11631853785900792,"row":1}]}],"channels":[["Glitch/amp",{"items":[{},{"time":10.666666666666666,"length":1,"curve":0},{"time":256}]}],["PixelSorter/amp",{"items":[{},{"time":15.666666666666666,"length":1.666666666666666,"curve":1}]}],["Music/NEURO_TIME",{"items":[{"time":42.666666666666664,"length":10.666666666666664,"curve":2},{"time":53.33333333333333,"length":8.666666666666671,"curve":2},{"time":62,"length":1.999999999999993,"curve":9},{"time":63.99999999999999,"length":10.666666666666664,"curve":2},{"time":74.66666666666666,"length":8.666666666666671,"curve":2},{"time":83.33333333333333,"length":1.999999999999993,"curve":9}]}],["Music/NEURO_DETUNE",{"items":[{"time":42.666666666666664,"length":10.666666666666664,"curve":3},{"time":53.33333333333333,"length":8.666666666666671,"curve":3},{"time":62,"length":1.999999999999993,"curve":10},{"time":63.99999999999999,"length":10.666666666666664,"curve":3},{"time":74.66666666666666,"length":8.666666666666671,"curve":3},{"time":83.33333333333333,"length":1.999999999999993,"curve":10}]}],["Music/NEURO_DETUNE_PHASE",{"items":[{"time":42.666666666666664,"length":10.666666666666664,"curve":8},{"time":53.33333333333333,"length":8.666666666666671,"curve":8},{"time":62,"length":1.999999999999993,"curve":11},{"time":63.99999999999999,"length":10.666666666666664,"curve":8},{"time":74.66666666666666,"length":8.666666666666671,"curve":8},{"time":83.33333333333333,"length":1.999999999999993,"curve":11}]}],["Music/NEURO_WUB_AMP",{"items":[{"time":42.666666666666664,"length":10.668578038364203,"curve":4},{"time":53.33524470503087,"length":8.664755294969133,"curve":4},{"time":62,"length":2.0038227433950624,"curve":12},{"time":64.00382274339506,"length":10.668578038364203,"curve":4},{"time":74.67240078175926,"length":8.660932551574064,"curve":4},{"time":83.33333333333333,"length":2.0038227433950624,"curve":12}]}],["Music/NEURO_WUB_FREQ",{"items":[{"time":42.666666666666664,"length":2,"value":1},{"time":44.666666666666664,"length":0.6666666666666643,"value":0.49999999999999967},{"time":45.33333333333333,"length":0.6666666666666714,"value":1},{"time":46,"length":1.3333333333333286,"value":2},{"time":47.33333333333333,"length":0.6666666666666714,"value":2.5},{"time":48,"length":0.6666666666666643,"value":1},{"time":48.666666666666664,"length":1.3333333333333357,"value":1},{"time":50,"length":0.6666666666666643,"value":2},{"time":50.666666666666664,"length":2,"value":1},{"time":52.666666666666664,"length":0.6666666666666643,"value":2},{"time":53.33333333333333,"length":0.6666666666666714,"value":1},{"time":54,"length":1.3333333333333286,"value":2.1000000000000014},{"time":55.33333333333333,"length":0.6666666666666714,"value":0.5},{"time":56,"length":0.6666666666666643,"value":7},{"time":56.666666666666664,"length":1.3333333333333357,"value":3},{"time":58,"length":0.6666666666666714,"value":1},{"time":58.66666666666667,"length":0.6666666666666714,"value":3},{"time":59.33333333333334,"length":2,"value":6},{"time":61.33333333333334,"length":0.6666666666666572,"value":1},{"time":62,"length":1.3333333333333428,"value":4.1},{"time":63.33333333333334,"length":0.6666666666666572,"value":4.109999999999999},{"time":64,"length":2,"value":1},{"time":66,"length":0.6666666666666643,"value":0.49999999999999967},{"time":66.66666666666666,"length":0.6666666666666714,"value":1},{"time":67.33333333333333,"length":1.3333333333333286,"value":2},{"time":68.66666666666666,"length":0.6666666666666714,"value":2.5},{"time":69.33333333333333,"length":0.6666666666666643,"value":1},{"time":70,"length":1.3333333333333357,"value":1},{"time":71.33333333333334,"length":0.6666666666666643,"value":2},{"time":72,"length":2,"value":1},{"time":74,"length":0.6666666666666643,"value":2},{"time":74.66666666666666,"length":0.6666666666666714,"value":1},{"time":75.33333333333333,"length":1.3333333333333286,"value":2.1000000000000014},{"time":76.66666666666666,"length":0.6666666666666714,"value":0.5},{"time":77.33333333333333,"length":0.6666666666666643,"value":7},{"time":78,"length":1.3333333333333357,"value":3},{"time":79.33333333333334,"length":0.6666666666666714,"value":1},{"time":80.00000000000001,"length":0.6666666666666714,"value":3},{"time":80.66666666666669,"length":2,"value":6},{"time":82.66666666666669,"length":0.6666666666666572,"value":1},{"time":83.33333333333334,"length":1.3333333333333428,"value":4.1},{"time":84.66666666666669,"length":0.6666666666666572,"value":4.109999999999999}]}]],"labels":{"zero":0},"guiSettings":{"snapTimeActive":true,"snapTimeInterval":0.1,"snapValueActive":true,"snapValueInterval":0.1,"snapBeatActive":true,"bpm":180,"beatOffset":0,"useBeatInGUI":true,"minimizedPrecisionTime":3,"minimizedPrecisionValue":3}} \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index 9f4b8b9..05db074 100644 --- a/src/config.ts +++ b/src/config.ts @@ -5,4 +5,5 @@ export const AO_RESOLUTION_RATIO = 1.0, RESOLUTION = [ 1280, 720 ], MUSIC_BPM = 180, - MUSIC_BUFFER_LENGTH = 4096; + MUSIC_BUFFER_LENGTH = 4096, + MUSIC_AUTOMATON_TEXTURE_HEIGHT = 16; diff --git a/src/shaders/music.vert b/src/shaders/music.vert index 04a3bc0..92db011 100644 --- a/src/shaders/music.vert +++ b/src/shaders/music.vert @@ -40,8 +40,8 @@ in float off; out float outL; out float outR; -float auto( int index ) { - return texture( samplerAutomaton, vec2( off / bufferLength, ( float( index ) + 0.5 ) / 256.0 ) ).x; +float auto( float y ) { + return texture( samplerAutomaton, vec2( off / bufferLength, y ) ).x; } float fs( float s ) { @@ -372,7 +372,6 @@ vec2 mainAudio( vec4 time ) { // -- snare -------------------------------------------------------------------------------------- if ( inRange( time.w, SECTION_NEURO, SECTION_PORTER_FUCKING_ROBINSON ) ) { float t = mod( time.y - 2.0 * BEAT, 4.0 * BEAT ); - // float t = mod( time.z - 2.0 * BEAT, 4.0 * BEAT ); dest += 0.12 * snare( t ); } @@ -391,7 +390,7 @@ vec2 mainAudio( vec4 time ) { float tt = t + det * fi * sin( fi * detPhase + 1.0 * t ); - float radius = 0.2 + 0.1 * wubIntensity * fbm( 0.1 * vec2( tri( n2f( -36.0 ) * wubFreq * tt ) ) ).x; + float radius = 0.1 * wubIntensity * fbm( 0.1 * vec2( sin( TAU * n2f( -36.0 ) * wubFreq * tt ) ) ).x; float phase = 0.2 * tri( n2f( -36.0 ) * tt ); vec2 uv = radius * vec2( sin( phase ), cos( phase ) ) + 0.4;