Skip to content

Commit

Permalink
- Loris Toolbox: fix compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Apr 11, 2023
1 parent d449584 commit 4d35fd9
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions Loris Toolbox/Scripts/LorisProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,31 +234,34 @@ namespace LorisProcessor

function detectPitch()
{
var data = CURRENT_FILE.loadAsAudioFile();

var isMultiChannel = isDefined(data[0].length);

if(isMultiChannel)
data = data[0];

var pitch = data.detectPitch(CURRENT_FILE.loadAudioMetadata().SampleRate, data.length * 0.2, data.length * 0.6);

if(pitch != 0.0)
if(isDefined(CURRENT_FILE) && CURRENT_FILE.isFile())
{
for(i = 0; i < 127; i++)
{
var thisPitch = Engine.getFrequencyForMidiNoteNumber(i);

var ratio = Math.abs(1.0 - thisPitch / pitch);
var data = CURRENT_FILE.loadAsAudioFile();

var isMultiChannel = isDefined(data[0].length);

if(isMultiChannel)
data = data[0];

if(ratio < 0.05)
var pitch = data.detectPitch(CURRENT_FILE.loadAudioMetadata().SampleRate, data.length * 0.2, data.length * 0.6);

if(pitch != 0.0)
{
for(i = 0; i < 127; i++)
{
Console.print("FOUND");
var thisPitch = Engine.getFrequencyForMidiNoteNumber(i);


rootNote.setValue(i+1);
rootNote.sendRepaintMessage();
return;
var ratio = Math.abs(1.0 - thisPitch / pitch);

if(ratio < 0.05)
{
Console.print("FOUND");


rootNote.setValue(i+1);
rootNote.sendRepaintMessage();
return;
}
}
}
}
Expand All @@ -268,10 +271,10 @@ namespace LorisProcessor
{
CURRENT_FILE = FileSystem.fromReferenceString(file, FileSystem.AudioFiles);

detectPitch();

if(isDefined(CURRENT_FILE))
{
detectPitch();

this.callOnBackgroundThread(rebuild);
}
});
Expand Down

0 comments on commit 4d35fd9

Please sign in to comment.