Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode functions #1

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
bec715d
Update README.md
ExpressMix May 27, 2019
1fdbd49
Add files via upload
ExpressMix May 27, 2019
65a5d33
Update functions.js
ExpressMix May 27, 2019
605a35c
Update README.md
ExpressMix May 27, 2019
be4a6c1
Add files via upload
ExpressMix May 27, 2019
4ea538e
Update README.md
ExpressMix May 27, 2019
99e358b
Add files via upload
ExpressMix May 27, 2019
e7dbff8
Update README.md
ExpressMix May 27, 2019
6d34936
Add files via upload
ExpressMix May 28, 2019
969e925
Update README.md
ExpressMix May 28, 2019
f81e1c3
Add files via upload
ExpressMix May 28, 2019
2fb2a38
Update README.md
ExpressMix May 28, 2019
9d7f756
Add files via upload
ExpressMix May 28, 2019
435c562
Update README.md
ExpressMix May 28, 2019
4503da6
Added loadCubasePatchScript function
ExpressMix Jun 8, 2019
69aec12
Update README.md
ExpressMix Jun 8, 2019
db72c3f
Added loadCubasePatchScript function
ExpressMix Jun 8, 2019
692c159
Fixed cubase path code
ExpressMix Jun 8, 2019
6362385
fixed code
ExpressMix Jun 10, 2019
95cd796
Update README.md
ExpressMix Jun 10, 2019
769ec7b
Added code samples
ExpressMix Jun 10, 2019
026c314
Update README.md
ExpressMix Jun 10, 2019
adacc45
Added resetInputs()
ExpressMix Jun 14, 2019
a45670e
Update README.md
ExpressMix Jun 14, 2019
f52fa0f
Decoded
aminya Dec 11, 2019
feae133
MESSAGING
aminya Dec 11, 2019
436901e
getDateTime
aminya Dec 11, 2019
fc9b350
vTrack
aminya Dec 11, 2019
c5e0800
selectTrack
aminya Dec 11, 2019
161ba2d
vSelected
aminya Dec 11, 2019
2c4aca5
getTracks
aminya Dec 11, 2019
defa20a
getTracksByName
aminya Dec 11, 2019
226d19d
renameTracks
aminya Dec 11, 2019
a86e9af
getPan
aminya Dec 11, 2019
2379d3c
setPan
aminya Dec 11, 2019
4b9c705
vValue
aminya Dec 11, 2019
8674fd3
getChannels
aminya Dec 11, 2019
e733720
getChannelsByName
aminya Dec 11, 2019
6f8429d
vName
aminya Dec 11, 2019
8b8034f
vCaseMatching
aminya Dec 11, 2019
3e2ba20
vChannel
aminya Dec 11, 2019
53a252d
setFader
aminya Dec 11, 2019
2f71a57
vLevel
aminya Dec 11, 2019
204bf96
centerPans
aminya Dec 11, 2019
992a59e
resetInputs
aminya Dec 11, 2019
561bdcf
setMasterFader
aminya Dec 11, 2019
5820ad4
vLevel
aminya Dec 11, 2019
57b4e06
vColor
aminya Dec 11, 2019
3038cd6
loadCubasePatchFile
aminya Dec 11, 2019
f26d7fe
vDebug
aminya Dec 11, 2019
73f7969
setProgram
aminya Dec 11, 2019
bcea3df
setTrackColor
aminya Dec 11, 2019
730cae4
Organizing
aminya Dec 11, 2019
3e90092
vTrackList
aminya Dec 11, 2019
e41f593
vFind vReplace
aminya Dec 11, 2019
61d424c
vChannelList
aminya Dec 11, 2019
0300f8e
vFileSelector
aminya Dec 11, 2019
3f0250b
vCubasePatch
aminya Dec 11, 2019
bef859d
vPath
aminya Dec 11, 2019
07187fa
vFile
aminya Dec 11, 2019
5f5162a
Add examples
aminya Dec 11, 2019
a121f39
getAllPropertyNames
aminya Dec 11, 2019
3a07b2e
vOutTrack
aminya Dec 11, 2019
1f1e3c2
vTrackNameTrimed
aminya Dec 11, 2019
fa568e6
vChannelOut
aminya Dec 11, 2019
5814848
vChannelLabelTrimmed
aminya Dec 11, 2019
68aa7e2
vStudioOneVersion
aminya Dec 11, 2019
a26fb1a
vChannelsSelected
aminya Dec 11, 2019
9c9dbd6
vAudioMixer
aminya Dec 11, 2019
1340a4f
vChannelName
aminya Dec 11, 2019
806ed4b
vOutArray
aminya Dec 11, 2019
652ff53
idx
aminya Dec 11, 2019
3cf91b2
vTextLine
aminya Dec 11, 2019
2dd2e6a
loadCubasePatchFile
aminya Dec 11, 2019
ea8d248
Update README.md
aminya Dec 11, 2019
6830a3a
vTracks vNameNew
aminya Dec 11, 2019
df0c8a4
Merge branch 'master' of https://github.com/aminya/studioone_functions
aminya Dec 11, 2019
6e11f90
vTracksFunction
aminya Dec 11, 2019
8e457bc
vProgram
aminya Dec 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 196 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,196 @@
# studioone_functions
functions include file for PreSonus Studio One 4.5 +
# functions.js
A few basic functions to help with developing scripts for PreSonus Studio One 4.5+.

<HR>

**How To Use:**</br>

Right click the link and **Save As...** to download:
[functions.js](https://raw.githubusercontent.com/expressmix/studioone_functions/master/functions.js) </br>
Copy it to your script project folder(s) and add **_include_file('functions.js')_** to the top of your JS code file.

_There is error handling in the functions but if you encounter any errors with any function please leave a detailed comment here explaining the use so it can be trapped._

<HR>

### MESSAGING

- **alert** (value)</br>
Common alert box, string formatting is performed in the function

- **print** (value)</br>
Write to console, string formatting is performed in the function</br>
Outputs to the Studio One message window

<HR>

### TRACKS

- **getTracks** (_selected [bool]_)</br>
Returns an array of arrange tracks</br>
Argument is optional: None or 0 = all tracks, 1 = selected tracks

- **getTracksByName** (string, _[integer]_)</br>
Returns an array of tracks where the track name contains the string. </br>
Optional case sensitivy matching: 0 or none = no case sensitivity, 1 = case sensitive

- **renameTracks** (find _[string]_, replace _[string]_)</br>
Replace parts of all track names. Case sensitive matching (search string, replacment string)

- **selectTrack** (track _[object]_)</br>
Use this to optionally select tracks when iterating when necessary

- **setTrackColor** (track _[object]_, color _[hex]_)</br>
Sets a track to a hex color, # char irrelevant

- **getPan** (track _[object]_)</br>
Returns the pan value from a track's channel if any

- **setPan** (track _[object]_, value _[string]_)</br>
Sets the pan value for a track's channel if any
_setPan(track, 'L45')_

<HR>

### CHANNELS </br>
_[does not include input or sub-out channels]_

- **resetInputs** (_selected [bool]_)</br>
Set input gains to unity
Argument is optional: None or 0 = all, 1 = selected

- **getChannels** (_selected [bool]_)</br>
Returns an array of mixer channels</br>
Argument is optional: None or 0 = all Channels, 1 = selected channels

- **getChannelsByName** (name _[string]_, caseMatching _[bool]_)</br>
Returns an array of mixer channels where the channel name contains the string.</br>
Optional case sensitivy matching: 0 or none = no case sensitivity, 1 = case sensitive


- **getFader** (channel _[object]_)</br>
Returns a fader level in dB.

- **setFader** (channel _[object]_, level _[integer]_)</br>
Sets a fader to a specific dB value. -144 to 10

- **setMasterFader** (level _[integer]_)</br>
Sets the master bus fader to a specific dB value. </br>
_Example: setMasterFader( -10.5);_

- **setChannelColor** (channel _[object]_, color _[hex]_)</br>
Sets a channel to a hex color, # char irrelevant

- **centerPans ()**</br>
Centers pans on all selected channel(s)

<HR>

### EXTERNAL INSTRUMENTS

_You can use this function in your own custom patch manager script, to send program and bank changes out to MIDI hardware._

- **setProgram** (bank _[integer]_, program _[integer]_)</br>
Set bank and program for an external instrument

- **loadCubasePatchFile** (debug _[integer]_)</br>
Returns an array from a Cubase patch script (.txt) file.</br>
_Argument is optional. 1 = print array to console.</br>_
Array item 0 is the Instrument Name, all other array items are comma delimited as follows:</br>
_Program Name, program number, bank number, group name_


<HR>

### MISCELLANEOUS

- **Mute:** if (track.channel != undefined) {track.channel.mute = 1};
- **Solo:** if {track.channel != undefined) {track.channel.solo = 1);
- **Fire an Action:** Host.GUI.Commands.interpretCommand("category","action")
- **getDateTime ():** Returns month/day/year (hour_minute_seconds)

<HR>

### SCRIPT PACKAGE EXAMPLE

A Studio One script package consists of *(at minimum)* three files as outlined below, zipped with a **.package** extender.
*You can use this package to test various functions in functions.js.*

### **metainfo.xml**
*Meta information for the script package.*

***Package:ID** must be unique*
```
<?xml version="1.0" encoding="UTF-8"?>
<MetaInformation>
<Attribute id="Package:ID" value="test.functions"/>
<Attribute id="Package:SkinFile" value="skin/"/>
<Attribute id="Package:TranslationFile" value="translations/"/>
<Attribute id="Package:Version" value="1.0.0/"/>
</MetaInformation>
```

### **classfactory.xml**
*Class definitions for each individual action.*

***ClassID's** must be unique.
**menuPriority** value="-1" is don't list in menu*
```
<?xml version="1.0" encoding="UTF-8"?>
<ClassFactory>
<ScriptClass
classID="{80CBE1FC-3EC1-4A97-A79E-FC46990FAEE8}"
category="EditTask"
subCategory="TrackEdit"
name="TEST FUNCTIONS"
sourceFile="code.js"
functionName="createInstance"
metaClassID="{B6099740-B26D-4BC3-A471-CBAAAED8CADC}">
<Attribute id="menuPriority" value="0"/>
</ScriptClass>
</ClassFactory>
```

### **code.js**
*JavaScript code file.*

***createInstance()** is the entry function used by classFactory.xml in this example although the name of that function and of this js code file are both irrelevant, they only have to match the names used in classfactory.xml.*
```
include_file('functions.js')
function testFunctions()
{
this.interfaces = [Host.Interfaces.IEditTask];

this.prepareEdit = function (context)
{
return Host.Results.kResultOk;
}

this.performEdit = function (context)
{
// ---------------------------------------
// return all tracks with 'voc' in the name
var tracks = getTracksByName('voc')
for (i = 0; i < tracks.length; i++)
{
// do something
}

// ----------------------------------------

// test print Cubase patch script programs
// array to console, arg(1)
// opens file selector dialog
var inst = loadCubasePatchFile(1);

return Host.Results.kResultOk;
}
}

// Entry Function ---------------------------------

function createInstance ()
{
return new testFunctions;
}
```
Loading