Class: View

View()

The view class stores the state of the view of the app and handles all interactions with the DOM and other widgets.

Constructor

new View()

Source:

Members

audioFiles

Array containing [name, data] pairs corresponding to all loaded audio files
Source:

dialogShouldReopen

This is a hack for reopening the dialog on adding new parameters. The methods AddParameter() and RemoveParameter() toggle dialogShouldReopen. We can then check dialogShouldReopen on closing our dialog to determine whether we should reshow the dialog.
Source:

instrumentMap

The instrument map contains all the instruments keyed by name.
Source:

paramList

An array to store the list of parameters for the in progress instrument
Source:

pianoRollVCellDefault

The default number of cells for a pianoroll widget.
Source:

sliderVCellDefault

The default number of vertical divisions for slider type widgets
Source:

trackLaneObject

The TrackLane object of the program. This widget corresponds to the canvas in the playlist editor of the program.
Source:

trackMap

The track map contains all tracks keyed by name
Source:

Methods

AddCanvas(canvasDiv, prefix, name)

Add canvas to either the instrument editor or track editor.
Parameters:
Name Type Description
canvasDiv string The canvas div to modify (differs based on whether this is an instrument or track).
prefix string Prefix used to specify whether the new canvas is an instrument or track.
name string The name of the instrument/track to be added.
Source:

AddParameter()

Add a a parameter to the new instrument modal dialog.
Source:

CheckDialogReopen()

Check if the track dialog modal needs reopened. If so reshow it.
Source:

CleanName(name)

Delete whitespace from the input name string
Parameters:
Name Type Description
name string The string containing the name we want to clean.
Source:

DecrementPlaylistBlockSize()

decrease the blocksize for the playlist editor.
Source:

DeleteInstrumentSelection()

Delete the currently selected instrument.
Source:

DeleteSelectOptionHelper(select, value)

Deletes value from select tag.
Parameters:
Name Type Description
select string Id of select tag to delete from.
value string The value to be deleted.
Source:

DeleteTrackSelection()

Delete the currently selected track.
Source:

EnterHandler()

Hack to catch enter button presses on form inputs for adding canvases.
Source:

HideAllCanvases(divId)

Hides all canvases attached to the specified div.
Parameters:
Name Type Description
divId string The div to hide attached canvases of.
Source:

IncrementPlaylistBlockSize()

Increase the blocksize for the playlist editor.
Source:

InstrumentCanvasHelper(canvasDiv, name)

Helper to build all instrument canvases.
Parameters:
Name Type Description
canvasDiv string The div containing instrument canvases.
name string The name of the instrument to be added.
Source:

NextParameter()

Display next parameter for the currently selected instrument.
Source:

OpenTab(tabName, btnID)

Opens the corresponding tab.
Parameters:
Name Type Description
tabName string The name of the tab to be opened.
btnID string The button clicked to open the tab.
Source:

PatternSelect()

Handles selection in playlist editor tab.
Source:

PrevParameter()

Display previous parameter for the currently selected instrument.
Source:

RemoveParameter()

Remove a a parameter to the new instrument modal dialog.
Source:

ResetParameter()

Reset display of currently selected instrument to show only the 0th parameters widget and hide all others.
Source:

ResetPlaylist()

Reset the playlist object.
Source:

SelectDropDown(divId, value)

Updates display when drop down is changed. This is mainly used for switching tracks/instruments in the track and instrument editor tabs.
Parameters:
Name Type Description
divId string The div containing the canvases to select from.
value string The canvas to be selected.
Source:

TrackCanvasHelper(canvasDiv, name)

Helper to build all track canvases.
Parameters:
Name Type Description
canvasDiv string The div containing track canvases.
name string The name of the track to be added.
Source:

buildInstrument(text)

Given instrument state in a string create/load the instrument into the project. See saveInstrument() code to better understand the instrument text format.
Parameters:
Name Type Description
text string An instrument in text form.
Source:

buildTrack(text, filename)

Given track state in a string create/load the track into the project. See saveTrack() code to better understand the instrument text format.
Parameters:
Name Type Description
text string A track in text form.
filename string Name of the file the track is being loaded from.
Source:

configureNode()

Configures the currently selected node based on the node dialog in the instrument editor.
Source:

getAudioFiles()

Returns the array of audio files that View keeps track of.
Source:

getOrchestraFooter() → {string}

Returns a string containing code intended to be emitted at the end of the orchestra code.
Source:
Returns:
Returns string containing the desired code.
Type
string

getOrchestraHeader() → {string}

Returns a string containing code intended to be emitted at the start of the orchestra code.
Source:
Returns:
Returns string containing the desired code.
Type
string

getScoreFooter() → {string}

Returns a string containing code intended to be emitted at the end of the score code.
Source:
Returns:
Returns string containing the desired code.
Type
string

getScoreHeader() → {string}

Returns a string containing code intended to be emitted at the start of the score code.
Source:
Returns:
Returns string containing the desired code.
Type
string

loadAudioFile()

Prompt user for an audio file and load the audio file into memory/csound. NOTE: This code requires the csound engine already be initialized to run due to csound needing to be initialized in order for us to load samples into it.
Source:

loadInstrument()

Prompt user for .synth file and create/load the instrument from the selected file.
Source:

loadProject()

Prompt user for a zip file containing a project and load the project from the file. NOTE: This code requires the csound engine already be initialized to run due to csound needing to be initialized in order for us to load samples into memory correctly.
Source:

loadTrack()

Prompt user for .track file and create/load the track from the selected file.
Source:

playPattern()

Render and play back the currently selected pattern.
Source:

playTrack()

Render and play back the entire project so far.
Source:

renderCSD(displayModal) → {string}

Render a CSD corresponding the whole project so far.
Parameters:
Name Type Description
displayModal boolean true/false to display a modal on the page containing the rendered code.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

renderInstrument()

Render the currently selected instrument to text and display in a pop up modal.
Source:

renderOrchestra(displayModal) → {string}

Render the orchestra.
Parameters:
Name Type Description
displayModal boolean true/false to display a modal on the page containing the orchestra code.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

renderPatternCSD(displayModal) → {string}

Render a CSD corresponding the currently selected pattern.
Parameters:
Name Type Description
displayModal boolean true/false to display a modal on the page containing the rendered code.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

renderScore(displayModal) → {string}

Render the entire score.
Parameters:
Name Type Description
displayModal boolean If true displays a modal containing generated code.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

renderTrack(offset, displayModal) → {string}

Render the currently selected track.
Parameters:
Name Type Description
offset number A time to offset generated times of track by.
displayModal boolean If true displays a modal containing generated code.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

renderTrackByName(bpm, name, offset) → {string}

Render a track by name.
Parameters:
Name Type Description
bpm number Bpm to use for rendering track.
name string The name of the track to render.
offset number Time to offset note events by.
Source:
Returns:
Returns string containing the text of the generated code.
Type
string

saveInstrument()

Generate and download a .synth file containing the currently selected instrument.
Source:

saveProject()

Create a zip file containing the full state of the current project and download it to the user computer.
Source:

saveTrack()

Generate and download a .track file containing the currently selected track.
Source:

stopPlayBack()

Stops playback if csound backend is playing audio.
Source: