EmNudge/Spectrogram-Replicator

JSON export

EmNudge opened this issue · 3 comments

Motivations
The application needs to output some format to be used on other platforms. JavaScript arrays of Symbol()s and classes cannot be exported. A noted platform was MATLAB, in which the best format would be arrays of arrays of arrays of arrays of numbers.
Yeah - a lot of arrays.

We're currently really complicating the UI since we're just throwing another button on the screen, but that will have to do for now.
The current system should allow transformations pretty easily. The questions is just whether nodes should be [x, y, volume] or [volume, x, y]. I think the former.

I just added in another button, but it works now. It takes each line and creates a schedule from it. Each schedule uses Point objects, so those are switched with arrays in an [x, y, volume] format.

It ultimately is an array of arrays of arrays of numbers.
An outer array to hold all the lines, each line is an array of nodes, and each node is an array of numbers.
We switched out segments in this system and now instead use a volume parameter in the Point array. It seems the less deep the arrays, the better, so that has been the current approach.

Something to be noted however is that the volume drops down and shoots up instantaneously, which is not a valid function. This may be problematic. The fading in and out is done after a schedule is received, not during the creation, which is why the application itself is fine with this.

Reopening this issue to add on some features.

  • move the x,y percentages from percentages to the actual values they represent
  • download a file instead of copying to clipboard

One of the problems with the download is that it's usually done with an <a> tag, not a button. The output isn't particularly difficult to generate, but it would be more efficient to only generate it when needed.
A possible solution is to generate the link's contents onMouseOver. The problems with this solution is that

  1. Each time the user moves his mouse over and out the button/link, it will be generated, regardless of if anything has actually changed to warrant that. This shouldn't be too bad though.
  2. It might be possible to click the button before it gets generated. Either if you click very quickly or if you use the keyboard.

Number 2 might be able to be resolved if we disable the link until onMouseOver and then disable it again onMouseOut.

It turns out we can click an <a> tag with .click(). I assumed this was a Puppeteer thing exclusively at it looked like a security issue of some sort, but it works just fine.

At the moment an <a> tag is generated, click, and then removed. It works fine.

A download location cannot be specified as websites do not have access to the file system. Names can be chosen, but the interface now looks very messy and I don't want to add in this just yet.

Added this in 9ca9915