Skip to content

Commit

Permalink
prog
Browse files Browse the repository at this point in the history
  • Loading branch information
jimomulloy committed Dec 24, 2024
1 parent d82c461 commit a6e7f36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,12 @@ public String convertToWav(String fileName) throws UnsupportedAudioFileException
AudioInputStream stream = AudioSystem.getAudioInputStream(bis);

AudioFormat sourceFormat = stream.getFormat();
float sampleRate = parameterManager
.getFloatParameter(InstrumentParameterNames.PERCEPTION_HEARING_DEFAULT_SAMPLE_RATE);
// create audio format object for the desired stream/audio format
// this is *not* the same as the file format (wav)
AudioFormat convertFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sourceFormat.getSampleRate(), 16,
sourceFormat.getChannels(), sourceFormat.getChannels() * 2, sourceFormat.getSampleRate(), true);
sourceFormat.getChannels(), sourceFormat.getChannels() * 2, sampleRate, true);
// AudioFormat convertFormat = new AudioFormat(sourceFormat.getSampleRate(), 16,
// 1, true, true);

Expand Down Expand Up @@ -626,10 +628,13 @@ public String cacheFile(String fileName) throws UnsupportedAudioFileException, I
AudioInputStream stream = AudioSystem.getAudioInputStream(bis);

AudioFormat sourceFormat = stream.getFormat();
float sampleRate = parameterManager
.getFloatParameter(InstrumentParameterNames.PERCEPTION_HEARING_DEFAULT_SAMPLE_RATE);

// create audio format object for the desired stream/audio format
// this is *not* the same as the file format (wav)
AudioFormat convertFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sourceFormat.getSampleRate(), 16,
sourceFormat.getChannels(), sourceFormat.getChannels() * 2, sourceFormat.getSampleRate(), true);
sourceFormat.getChannels(), sourceFormat.getChannels() * 2, sampleRate, true);
// AudioFormat convertFormat = new AudioFormat(sourceFormat.getSampleRate(), 16,
// 1, true, true);

Expand Down Expand Up @@ -664,13 +669,14 @@ public String cacheFile(String fileName) throws UnsupportedAudioFileException, I

public String resample(String fileName) throws UnsupportedAudioFileException, IOException {
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(fileName));
float sampleRate = parameterManager
.getFloatParameter(InstrumentParameterNames.PERCEPTION_HEARING_DEFAULT_SAMPLE_RATE);
AudioFormat sourceFormat = audioInputStream.getFormat();
AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 192000,
AudioFormat targetFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, sampleRate,
sourceFormat.getSampleSizeInBits(), sourceFormat.getChannels(), sourceFormat.getFrameSize(),
sourceFormat.getFrameRate(), sourceFormat.isBigEndian());

AudioInputStream inputStream = AudioSystem.getAudioInputStream(targetFormat, audioInputStream);

// write stream into a file with file format wav
String baseDir = storage.getObjectStorage().getBasePath();
String folder = Paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ perception.hearing.audioSourceDirectory=C:\\dev\\projects\\instrument\\instrumen
perception.hearing.tonemap.persistenceMode=2
# actuation.voice.midiSoundFonts=FluidR3_GM.sf2
storage.objectStore.basePath=user.home
actuation.voice.midiDevicePlaySwitch=true
actuation.voice.midiDevicePlaySwitch=false
actuation.voice.midiDeviceChannelSwitch=false
perception.hearing.maximumFrequencyInCents=8000
perception.hearing.cq.maximumFrequencyInCents=8000
perception.hearing.cq.minimumFrequencyInCents=2400

0 comments on commit a6e7f36

Please sign in to comment.