Skip to content

Commit

Permalink
bump to 1.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsijben committed Mar 13, 2024
1 parent 9d9d9ab commit 435350e
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 16 deletions.
11 changes: 9 additions & 2 deletions FrequencyAnalyzer.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ The FrequencyAnalyzer class provides the following main functions:

You can tweak the behaviour of this library with the following functions (you can also chain them when initializing your frequencyanalyzer object for clarity):
* `.addMinim(minim)` mandatory to add the global minim object to the class.
* `.setBandsPerOctave(6)` to get a total of 6 * 10 bands.
* `.setFile("example.mp3")` to set the file for the audioplayer.
* `.setAudioInputMode(AudioInputMode.AUDIO_FILE)` to set the input mode to AudioInputMode.AUDIO_FILE. You can also set it to AudioInputMode.LINE_IN or AudioInputMode.MICROPHONE. Defaults to AudioInputMode.MICROPHONE.
* `.setAudioOutputMode(AudioOutputMode.STEREO)` to set the output mode to AudioOutputMode.STEREO. Defaults to AudioOutputMode.MONO. Use it to get access to both left and right channel analysis.
Expand All @@ -69,7 +68,15 @@ You can tweak the behaviour of this library with the following functions (you ca
* `CTRL + 2` switch to MONO mode
* `CTRL + 3` switch to STEREO mode
* `CTRL + M` toggle monitoring on LINE_IN or MICROPHONE input


<!--
* `CTRL + R` reset the max value
* `getAvg(2)` function that returns normalized value of the frequency band with index 2. The normalization mapping is done by continuously checking the highest overall amplitude.
* `getAvg(2, 150)` function that returns normalized value of the frequency band with index 2, mapped with a max value of 150.
* `resetMaxValue()` function that resets the overall max value (to 0.1f).
* `.resetMaxValueDuration(2000)` to reset the max value every 2000 milliseconds.
* `.setBandsPerOctave(6)` to get a total of 6 * 10 bands.
-->

## Examples
You can find all these examples in `Processing -> File - Examples - Contributed Libraries - BPM timings - FrequencyAnalyzer`.
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ ln -s ../../../src/bpm/library/frequencyanalyzer/AudioInputSource.java ./example
ln -s ../../../src/bpm/library/frequencyanalyzer/MicrophoneInputSource.java ./examples/FrequencyAnalyzer/basics/MicrophoneInputSource.java
ln -s ../../../src/bpm/library/frequencyanalyzer/LineInInputSource.java ./examples/FrequencyAnalyzer/basics/LineInInputSource.java
ln -s ../../../src/bpm/library/InfoPanel.java ./examples/FrequencyAnalyzer/basics/InfoPanel.java
ln -s ../../../src/bpm/library/frequencyanalyzer/FrequencyAnalyzer.java ./examples/FrequencyAnalyzer/audio_file/FrequencyAnalyzer.java
ln -s ../../../src/bpm/library/frequencyanalyzer/AudioFileInputSource.java ./examples/FrequencyAnalyzer/audio_file/AudioFileInputSource.java
ln -s ../../../src/bpm/library/frequencyanalyzer/AudioInputMode.java ./examples/FrequencyAnalyzer/audio_file/AudioInputMode.java
ln -s ../../../src/bpm/library/frequencyanalyzer/AudioOutputMode.java ./examples/FrequencyAnalyzer/audio_file/AudioOutputMode.java
ln -s ../../../src/bpm/library/frequencyanalyzer/AudioInputSource.java ./examples/FrequencyAnalyzer/audio_file/AudioInputSource.java
ln -s ../../../src/bpm/library/frequencyanalyzer/MicrophoneInputSource.java ./examples/FrequencyAnalyzer/audio_file/MicrophoneInputSource.java
ln -s ../../../src/bpm/library/frequencyanalyzer/LineInInputSource.java ./examples/FrequencyAnalyzer/audio_file/LineInInputSource.java
ln -s ../../../src/bpm/library/InfoPanel.java ./examples/FrequencyAnalyzer/audio_file/InfoPanel.java
```
BPM_Timing examples:
```
Expand Down
1 change: 1 addition & 0 deletions examples/FrequencyAnalyzer/stereo_output/InfoPanel.java
Binary file not shown.
29 changes: 29 additions & 0 deletions examples/FrequencyAnalyzer/stereo_output/stereo_output.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Import the library to your sketch
import bpm.library.frequencyanalyzer.*;

// Import the minim library
import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
FrequencyAnalyzer fa;

void setup() {
size(500, 500);
minim = new Minim(this);

fa = new FrequencyAnalyzer(this)
.addMinim(minim)
.setFile("example-stereo.mp3")
.setAudioInputMode(AudioInputMode.AUDIO_FILE)
.setAudioOutputMode(AudioOutputMode.STEREO)
;
}


void draw() {
background(50);

circle(width/3, height/2, fa.getAvgRawLeft(0)*30);
circle(width/3*2, height/2, fa.getAvgRawRight(0)*30);
}
4 changes: 2 additions & 2 deletions resources/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ source.repository=https://github.com/vincentsijben/bpm-tmings-for-processing.git
# This is used to compare different versions of the same Library, and check if
# an update is available.

library.version=8
library.version=9


# The version as the user will see it.

library.prettyVersion=1.1.3
library.prettyVersion=1.1.4


# The min and max revision of Processing compatible with your Library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ddf.minim.*;
import ddf.minim.analysis.*;

//test
class AudioFileInputSource implements AudioInputSource {
Minim minim;
FFT fftLeft, fftRight, fftMixed;
Expand Down
20 changes: 9 additions & 11 deletions src/bpm/library/frequencyanalyzer/FrequencyAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ public class FrequencyAnalyzer {
AudioInputSource currentInputSource;
private AudioPlayer audioPlayer;
private String file;
//private AudioInput audioInput;
//private AudioBuffer audioBufferMix;
//private AudioBuffer audioBufferLeftt;
//private AudioBuffer audioBufferRight;
private int bandsPerOctave;
// private int bandsPerOctave;

private InfoPanel infoPanel;
private AudioInputMode currentInputMode;
Expand Down Expand Up @@ -56,11 +52,11 @@ public FrequencyAnalyzer addMinim(Minim minim) {
return this;
}

public FrequencyAnalyzer setBandsPerOctave(int bandsPerOctave) {
this.bandsPerOctave = bandsPerOctave;
//this.fft.logAverages(22, bandsPerOctave ); // 3 results in 30 bands. 1 results in 10 etc.
return this;
}
//public FrequencyAnalyzer setBandsPerOctave(int bandsPerOctave) {
// this.bandsPerOctave = bandsPerOctave;
// //this.fft.logAverages(22, bandsPerOctave ); // 3 results in 30 bands. 1 results in 10 etc.
// return this;
//}

public FrequencyAnalyzer setFile(String file) {
this.file = file;
Expand Down Expand Up @@ -99,10 +95,12 @@ public FrequencyAnalyzer setAudioInputMode(AudioInputMode newMode) {
currentInputSource = new LineInInputSource(minim);
break;
case AUDIO_FILE:
if (this.file == null) System.out.println("no audio file was set");

//currentInputSource = new AudioFileInputSource(minim, "https://github.com/vincentsijben/bpm-timings-for-processing/raw/main/assets/infraction_music_-_ritmo.mp3"); // Assuming an AudioFileSource class exists
currentInputSource = new AudioFileInputSource(minim, this.file); // Assuming an AudioFileSource class exists
//"stereotest.mp3"

break;
}

Expand Down

0 comments on commit 435350e

Please sign in to comment.