Skip to content

Commit

Permalink
harps
Browse files Browse the repository at this point in the history
  • Loading branch information
jimomulloy committed Dec 28, 2023
1 parent 986ec7c commit b071bce
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void accept(List<NuMessage> messages) throws InstrumentException {
ToneTimeFrame ttf = toneMap.getTimeFrame(sequence);
ToneTimeFrame previousTimeFrame = toneMap.getPreviousTimeFrame(ttf.getStartTime());

LOG.finer(">>CQ TIME: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", " + ttf.getMinAmplitude()
LOG.severe(">>CQ TIME: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", " + ttf.getMinAmplitude()
+ ", " + ttf.getRmsPower());

ttf.reset();
Expand Down Expand Up @@ -207,7 +207,7 @@ public void accept(List<NuMessage> messages) throws InstrumentException {

ttf.filter(toneMapMinFrequency, toneMapMaxFrequency);

LOG.finer(">>CQ Before calibrate: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", "
LOG.severe(">>CQ Before calibrate: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", "
+ ttf.getMinAmplitude() + ", " + ttf.getRmsPower());

if (cqSwitchScale) {
Expand All @@ -218,7 +218,7 @@ public void accept(List<NuMessage> messages) throws InstrumentException {
CalibrationMap cm = workspace.getAtlas()
.getCalibrationMap(streamId);
ttf.calibrate(toneMap, cm, calibrateRange, calibrateForwardSwitch, lowThreshold, false);
LOG.finer(">>CQ After calibrate: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", "
LOG.severe(">>CQ After calibrate: " + ttf.getStartTime() + ", " + ttf.getMaxAmplitude() + ", "
+ ttf.getMinAmplitude() + ", " + ttf.getRmsPower());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public void accept(List<NuMessage> messages) throws InstrumentException {
if (synthToneMap != null && this.parameterManager
.getBooleanParameter(InstrumentParameterNames.ACTUATION_VOICE_LOOP_SAVE)) {
voice.startStreamPlayer(streamId, synthToneMap);
} else {
// hearing.replayAudioStream(streamId);
}
}).start();
// console.getVisor().updateViewThresholds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,40 @@ public void closeAudioStream(String streamId) {
LOG.severe(">>Closed Audio Stream: " + streamId);
}

public void replayAudioStream(String streamId) {
LOG.severe(">>Replay Audio Stream: " + streamId);
AudioStream audioStream = audioStreams.get(streamId);
if (audioStream == null) {
return;
}
voice.reset();
workspace.getAtlas()
.removeMapsByStreamId(streamId);

String filePath = parameterManager.getParameter(InstrumentParameterNames.PERCEPTION_HEARING_AUDIO_INPUT_FILE);

try {
is = new FileInputStream(filePath);
bs = new BufferedInputStream(is);
AudioFormat format = AudioSystem.getAudioFileFormat(bs)
.getFormat();
audioStream.setAudioFileName(
parameterManager.getParameter(InstrumentParameterNames.PERCEPTION_HEARING_AUDIO_INPUT_FILE));
audioStream.processAudioFileStream(bs, format);
} catch (UnsupportedAudioFileException | IOException | LineUnavailableException ex) {
LOG.log(Level.SEVERE, "Audio file init error:" + filePath, ex);
return;
// throw new Exception("Audio file init error: " + ex.getMessage());
}

audioStream.getAudioFeatureProcessor()
.addObserver(cortex);
audioStream.getAudioFeatureProcessor()
.addObserver(console.getVisor());
LOG.severe(">>!!RESTART Audio Stream: " + streamId);
audioStream.start();
}

public void removeAudioStream(String streamId) {
AudioStream audioStream = audioStreams.get(streamId);
if (audioStream == null) {
Expand Down Expand Up @@ -930,7 +964,9 @@ private void processAudioFileStream(BufferedInputStream inputStream, AudioFormat
}
LOG.severe(">>processAudioFileStream skip from secs: " + audioOffset / 1000.0);
TarsosDSPAudioInputStream audioStream = new JVMAudioInputStream(stream);
LOG.severe(">>processAudioFileStream length!!: " + ((double)audioStream.getFrameLength() / (audioStream.getFormat().getFrameRate())) + bufferSize + ", " + overlap + ", " + audioStream.getFormat());
LOG.severe(">>processAudioFileStream length!!: "
+ ((double) audioStream.getFrameLength() / (audioStream.getFormat().getFrameRate())) + bufferSize
+ ", " + overlap + ", " + audioStream.getFormat());
dispatcher = audioDispatcherFactory.getAudioDispatcher(audioStream, bufferSize, overlap);

int audioHighPass = parameterManager
Expand Down Expand Up @@ -1297,14 +1333,14 @@ public boolean startAudioPlayer() throws UnsupportedAudioFileException, IOExcept
LOG.severe(">>PLAY :" + audioSourceFile + ", " + format);
int audioVolumeFactor = parameterManager
.getIntParameter(InstrumentParameterNames.ACTUATION_VOICE_AUDIO_VOLUME_PLAYBACK);
GainProcessor gainProcessor = new GainProcessor((double)audioVolumeFactor/100.0);
LOG.severe(">>PLAY :" + audioVolumeFactor + ", "+ audioSourceFile + ", " + format);
GainProcessor gainProcessor = new GainProcessor((double) audioVolumeFactor / 100.0);
LOG.severe(">>PLAY :" + audioVolumeFactor + ", " + audioSourceFile + ", " + format);
AudioPlayer audioPlayer = new AudioPlayer(format);

audioPlayerDispatcher = AudioDispatcherFactory.fromFile(file, audioStream.getBufferSize(), 0);
audioPlayerDispatcher.addAudioProcessor(gainProcessor);
audioPlayerDispatcher.addAudioProcessor(audioPlayer);

audioPlayerDispatcher.addAudioProcessor(new AudioProcessor() {

@Override
Expand All @@ -1328,7 +1364,7 @@ public void processingFinished() {
}
}
});

this.audioPlaybackRunning = true;
Thread t = new Thread(audioPlayerDispatcher, "Thread-Hearing-AudioPlayer" + System.currentTimeMillis());
t.setPriority(Thread.MAX_PRIORITY);
Expand Down
17 changes: 17 additions & 0 deletions instrument-core/src/main/resources/instrument-harmonics.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#Thu Dec 28 18:41:35 GMT 2023
audio.tuner.harmonicAccumulateSwitch=true
audio.tuner.harmonicAttenuateSwitch=false
audio.tuner.harmonicOperatorSwitch=true
audio.tuner.n1Switch=true
audio.tuner.n2Switch=true
audio.tuner.n3Switch=true
audio.tuner.n4Switch=true
audio.tuner.n5Switch=true
audio.tuner.n6Switch=true
audio.tuner.noteScan.attenuateSemitonesSwitch=false
audio.tuner.noteScan.attenuateUndertonesSwitch=false
monitor.tonemap.view.highThreshold=0.7
monitor.tonemap.view.lowThreshold=0.0001
monitor.view.showColour=true
perception.hearing.audioDefaultFile=c3eg-epiano-3.mp3
perception.hearing.cq.lowThreshold=0.001
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class ParametersPanel extends JPanel {
"neon-synth", "billevans", "inverted", "likesomeone", "likesomeone2", "likesomeone3", "jona", "beatles",
"stpauls",
"stpauls2", "holst", "abide",
"loopback", "loopmidi", "user", "ha1", "BB-SQ-1" };
"loopback", "loopmidi", "user", "ha1", "BB-SQ-1", "harmonics" };

private JTextField tunerHarmonicDriftFactorInput;
private ParameterManager parameterManager;
Expand Down

0 comments on commit b071bce

Please sign in to comment.