Skip to content

Commit

Permalink
gsuiAnalyser: prefix $
Browse files Browse the repository at this point in the history
  • Loading branch information
mr21 committed Feb 14, 2024
1 parent f481c1d commit f64bbe1
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions gsuiAnalyser/gsuiAnalyser.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ class gsuiAnalyser extends gsui0ne {
}

// .........................................................................
clear() {
$clear() {
this.#ctx.clearRect( 0, 0, this.$element.width, this.$element.height );
}
setResolution( w, h ) {
$setResolution( w, h ) {
const img = this.#ctx.getImageData( 0, 0, this.$element.width, this.$element.height );

this.$element.width = w;
this.$element.height = h;
this.#ctx.putImageData( img, 0, 0 );
}
draw( ldata, rdata ) {
$draw( ldata, rdata ) {
gsuiAnalyser.#moveImage( this.#ctx );
gsuiAnalyser.#draw( this.#ctx, ldata, rdata );
}
Expand All @@ -36,8 +36,8 @@ class gsuiAnalyser extends gsui0ne {
static #draw( ctx, ldata, rdata ) {
const w2 = ctx.canvas.width / 2;
const len = Math.min( w2, ldata.length );
const imgL = gsuiSpectrum.draw( ctx, ldata, w2 );
const imgR = gsuiSpectrum.draw( ctx, rdata, w2 );
const imgL = gsuiSpectrum.$draw( ctx, ldata, w2 );
const imgR = gsuiSpectrum.$draw( ctx, rdata, w2 );
const imgLflip = ctx.createImageData( len, 1 );

for ( let x = 0, x2 = len - 1; x < len; ++x, --x2 ) {
Expand Down
4 changes: 2 additions & 2 deletions gsuiAnalyser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
let buffer;
let absn;

analyser.setResolution( 100, 500 );
analyser.$setResolution( 100, 500 );

anL.fftSize = fftSize;
anR.fftSize = fftSize;
Expand Down Expand Up @@ -94,7 +94,7 @@
function frame() {
anL.getByteFrequencyData( anLData );
anR.getByteFrequencyData( anRData );
analyser.draw( anLData, anRData );
analyser.$draw( anLData, anRData );
requestAnimationFrame( frame );
}

Expand Down
6 changes: 3 additions & 3 deletions gsuiChannels/gsuiChannels.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class gsuiChannels extends gsui0ne {

this.#analyserW = width;
this.#analyserH = height;
chans.forEach( chan => chan.$analyser.setResolution( width, height ) );
chans.forEach( chan => chan.$analyser.$setResolution( width, height ) );
}
}
$updateAudioData( id, ldata, rdata ) {
this.#chans[ id ].$analyser.draw( ldata, rdata );
this.#chans[ id ].$analyser.$draw( ldata, rdata );
}
$selectChannel( id ) {
const chan = this.#chans[ id ];
Expand Down Expand Up @@ -115,7 +115,7 @@ class gsuiChannels extends gsui0ne {
GSUpopup.prompt( "Rename channel", "", GSUgetAttribute( this.#chans[ id ], "name" ) )
.then( name => this.$onchange( "renameChannel", id, name ) );
};
chan.$analyser.setResolution( this.#analyserW, this.#analyserH );
chan.$analyser.$setResolution( this.#analyserW, this.#analyserH );
if ( this.#chanSelected ) {
this.#updateChanConnections();
} else if ( id === "main" ) {
Expand Down
4 changes: 2 additions & 2 deletions gsuiDAW/gsuiDAW.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class gsuiDAW extends HTMLElement {
Object.seal( this );

this.clock.$onchangeDisplay = display => this.#dispatch( "changeDisplayClock", display );
this.spectrum.setResolution( 140 );
this.spectrum.$setResolution( 140 );
this.#actions = this.#elements.historyList.getElementsByClassName( "gsuiDAW-history-action" );
this.#elements.head.onclick = this.#onclickHead.bind( this );
this.#elements.cmpsCloudList.ondragstart = gsuiDAW.#ondragstartCmp.bind( null, "cloud" );
Expand Down Expand Up @@ -284,7 +284,7 @@ class gsuiDAW extends HTMLElement {

// .........................................................................
updateSpectrum( data ) {
this.#elements.spectrum.draw( data );
this.#elements.spectrum.$draw( data );
}
#unloadComposition() {
this.#cmpId = null;
Expand Down
2 changes: 1 addition & 1 deletion gsuiEnvelope/gsuiEnvelope.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class gsuiEnvelope extends HTMLElement {
g.release = prop === "release" ? val : GSUgetAttributeNum( this, "release" );
g.duration =
this.#dur = Math.max( g.attack + g.hold + g.decay + .5 + g.release, 2 );
g.draw();
g.$draw();
this.#updatePxPerBeat();
}

Expand Down
4 changes: 2 additions & 2 deletions gsuiEnvelopeGraph/gsuiEnvelopeGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class gsuiEnvelopeGraph extends HTMLElement {
this.#width = w;
this.#height = h;
GSUsetAttribute( this.#svg, "viewBox", `0 0 ${ w } ${ h }` );
this.draw();
this.$draw();
}
draw() {
$draw() {
if ( this.firstChild ) {
const pts = gsuiEnvelopeGraph.#getPoints(
this.#width, this.#height, this.duration,
Expand Down
4 changes: 2 additions & 2 deletions gsuiOscilloscope/gsuiOscilloscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class gsuiOscilloscope {
this.drawEnd();
}

setResolution( w, h ) {
$setResolution( w, h ) {
this.rootElement.width = w;
this.rootElement.height = h;
}
Expand All @@ -31,7 +31,7 @@ class gsuiOscilloscope {
drawEnd( fn ) {
this.fnEnd = fn || function() {};
}
draw( data ) {
$draw( data ) {
const ctx = this.ctx;
const w = this.rootElement.width;
const h = this.rootElement.height;
Expand Down
8 changes: 4 additions & 4 deletions gsuiSpectrum/gsuiSpectrum.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class gsuiSpectrum extends HTMLElement {
clear() {
this.#ctx.clearRect( 0, 0, this.#cnv.width, 1 );
}
setResolution( w ) {
$setResolution( w ) {
this.#cnv.width = w;
this.#cnv.height = 1;
}
draw( data ) {
this.#ctx.putImageData( gsuiSpectrum.draw( this.#ctx, data, this.#cnv.width ), 0, 0 );
$draw( data ) {
this.#ctx.putImageData( gsuiSpectrum.$draw( this.#ctx, data, this.#cnv.width ), 0, 0 );
}

// .........................................................................
Expand All @@ -43,7 +43,7 @@ class gsuiSpectrum extends HTMLElement {
[ 200, 128, 10, .8 ], // 7
[ 200, 200, 20, 1 ], // 8
];
static draw( ctx, data, width = data.length ) {
static $draw( ctx, data, width = data.length ) {
const img = ctx.createImageData( width, 1 );
const imgData = img.data;
const datalen = data.length;
Expand Down
4 changes: 2 additions & 2 deletions gsuiSpectrum/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
let buffer;
let absn;

spectrum.setResolution( 1024 );
spectrum.$setResolution( 1024 );

an.fftSize = fftSize;
an.smoothingTimeConstant = 0;
Expand Down Expand Up @@ -83,7 +83,7 @@

function frame() {
an.getByteFrequencyData( anData );
spectrum.draw( anData );
spectrum.$draw( anData );
requestAnimationFrame( frame );
}

Expand Down
6 changes: 3 additions & 3 deletions gsuiWaveform/gsuiWaveform.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class gsuiWaveform {
empty() {
this.polygon.removeAttribute( "points" );
}
setResolution( w, h ) {
$setResolution( w, h ) {
this.width = w;
this.height = h;
GSUsetAttribute( this.rootElement, "viewBox", `0 0 ${ w } ${ h }` );
Expand All @@ -43,9 +43,9 @@ class gsuiWaveform {
const off = offset || 0;
const dur = duration || buf.duration - off;

gsuiWaveform.draw( polygon, w, h, d0, d1, buf.duration, off, dur );
gsuiWaveform.$draw( polygon, w, h, d0, d1, buf.duration, off, dur );
}
static draw( polygon, w, h, data0, data1, bufDur, offset, dur ) {
static $draw( polygon, w, h, data0, data1, bufDur, offset, dur ) {
GSUsetAttribute( polygon, "points", gsuiWaveform.#getPolygonPoints( w, h, data0, data1, bufDur, offset, dur ) );
}
static getPointsFromBuffer( w, h, buf, offset, duration ) {
Expand Down

0 comments on commit f64bbe1

Please sign in to comment.