Browse Source

Convert to gradle project (#1)

* Convert to gradle project

* Update gradle wrapper to 4.8.1
master
Jamie Magee 4 years ago committed by Jamie Magee
parent
commit
e52b8b5d5a
  1. 113
      .gitignore
  2. 31
      build.gradle
  3. BIN
      gradle/wrapper/gradle-wrapper.jar
  4. 5
      gradle/wrapper/gradle-wrapper.properties
  5. 172
      gradlew
  6. 84
      gradlew.bat
  7. 1
      lib/export.txt
  8. BIN
      lib/jl1.0.1.jar
  9. BIN
      lib/jopt-simple-5.0.4.jar
  10. BIN
      lib/jsminim.jar
  11. BIN
      lib/jsoup-1.11.2.jar
  12. BIN
      lib/mp3spi1.9.5.jar
  13. BIN
      lib/tritonus_aos.jar
  14. BIN
      lib/tritonus_share.jar
  15. BIN
      lib/trove-3.0.3.jar
  16. 82
      src/ddf/minim/AudioBuffer.java
  17. 61
      src/ddf/minim/AudioEffect.java
  18. 171
      src/ddf/minim/AudioInput.java
  19. 72
      src/ddf/minim/AudioListener.java
  20. 243
      src/ddf/minim/AudioMetaData.java
  21. 541
      src/ddf/minim/AudioOutput.java
  22. 374
      src/ddf/minim/AudioPlayer.java
  23. 169
      src/ddf/minim/AudioRecorder.java
  24. 128
      src/ddf/minim/AudioSample.java
  25. 58
      src/ddf/minim/AudioSignal.java
  26. 146
      src/ddf/minim/AudioSnippet.java
  27. 309
      src/ddf/minim/AudioSource.java
  28. 117
      src/ddf/minim/BasicAudioOut.java
  29. 723
      src/ddf/minim/Controller.java
  30. 154
      src/ddf/minim/Effectable.java
  31. 254
      src/ddf/minim/EffectsChain.java
  32. 134
      src/ddf/minim/MAudioBuffer.java
  33. 1033
      src/ddf/minim/Minim.java
  34. 252
      src/ddf/minim/MultiChannelBuffer.java
  35. 183
      src/ddf/minim/NoteManager.java
  36. 154
      src/ddf/minim/Playable.java
  37. 148
      src/ddf/minim/Polyphonic.java
  38. 84
      src/ddf/minim/Recordable.java
  39. 303
      src/ddf/minim/SignalChain.java
  40. 185
      src/ddf/minim/SignalSplitter.java
  41. 59
      src/ddf/minim/StereoBuffer.java
  42. 676
      src/ddf/minim/UGen.java
  43. 64
      src/ddf/minim/UGenSignal.java
  44. 47
      src/ddf/minim/analysis/BartlettHannWindow.java
  45. 47
      src/ddf/minim/analysis/BartlettWindow.java
  46. 678
      src/ddf/minim/analysis/BeatDetect.java
  47. 65
      src/ddf/minim/analysis/BlackmanWindow.java
  48. 46
      src/ddf/minim/analysis/CosineWindow.java
  49. 151
      src/ddf/minim/analysis/DFT.java
  50. 404
      src/ddf/minim/analysis/FFT.java
  51. 940
      src/ddf/minim/analysis/FourierTransform.java
  52. 67
      src/ddf/minim/analysis/GaussWindow.java
  53. 48
      src/ddf/minim/analysis/HammingWindow.java
  54. 46
      src/ddf/minim/analysis/HannWindow.java
  55. 48
      src/ddf/minim/analysis/LanczosWindow.java
  56. 48
      src/ddf/minim/analysis/RectangularWindow.java
  57. 48
      src/ddf/minim/analysis/TriangularWindow.java
  58. 122
      src/ddf/minim/analysis/WindowFunction.java
  59. 76
      src/ddf/minim/analysis/package.html
  60. 81
      src/ddf/minim/effects/BandPass.java
  61. 406
      src/ddf/minim/effects/ChebFilter.java
  62. 142
      src/ddf/minim/effects/Convolver.java
  63. 49
      src/ddf/minim/effects/HighPassSP.java
  64. 228
      src/ddf/minim/effects/IIRFilter.java
  65. 64
      src/ddf/minim/effects/LowPassFS.java
  66. 51
      src/ddf/minim/effects/LowPassSP.java
  67. 76
      src/ddf/minim/effects/NotchFilter.java
  68. 110
      src/ddf/minim/effects/WavetableEnvelope.java
  69. 51
      src/ddf/minim/javasound/BasicMetaData.java
  70. 1181
      src/ddf/minim/javasound/FloatSampleBuffer.java
  71. 880
      src/ddf/minim/javasound/FloatSampleTools.java
  72. 182
      src/ddf/minim/javasound/JSAudioInput.java
  73. 176
      src/ddf/minim/javasound/JSAudioOutput.java
  74. 360
      src/ddf/minim/javasound/JSAudioRecording.java
  75. 161
      src/ddf/minim/javasound/JSAudioRecordingClip.java
  76. 61
      src/ddf/minim/javasound/JSAudioSample.java
  77. 716
      src/ddf/minim/javasound/JSBaseAudioRecordingStream.java
  78. 224
      src/ddf/minim/javasound/JSBufferedSampleRecorder.java
  79. 40
      src/ddf/minim/javasound/JSMPEGAudioRecordingStream.java
  80. 881
      src/ddf/minim/javasound/JSMinim.java
  81. 34
      src/ddf/minim/javasound/JSPCMAudioRecordingStream.java
  82. 186
      src/ddf/minim/javasound/JSStreamingSampleRecorder.java
  83. 111
      src/ddf/minim/javasound/MP3MetaData.java
  84. 895
      src/ddf/minim/javasound/MpegAudioFileReader.java
  85. 124
      src/ddf/minim/javasound/MpegAudioFileReaderWorkaround.java
  86. 139
      src/ddf/minim/javasound/SampleSignal.java
  87. 77
      src/ddf/minim/package.html
  88. 442
      src/ddf/minim/signals/Oscillator.java
  89. 171
      src/ddf/minim/signals/PinkNoise.java
  90. 82
      src/ddf/minim/signals/PulseWave.java
  91. 50
      src/ddf/minim/signals/SawWave.java
  92. 51
      src/ddf/minim/signals/SineWave.java
  93. 51
      src/ddf/minim/signals/SquareWave.java
  94. 51
      src/ddf/minim/signals/TriangleWave.java
  95. 120
      src/ddf/minim/signals/WhiteNoise.java
  96. 72
      src/ddf/minim/spi/AudioOut.java
  97. 121
      src/ddf/minim/spi/AudioRecording.java
  98. 119
      src/ddf/minim/spi/AudioRecordingStream.java
  99. 52
      src/ddf/minim/spi/AudioResource.java
  100. 54
      src/ddf/minim/spi/AudioStream.java
  101. Some files were not shown because too many files have changed in this diff Show More

113
.gitignore vendored

@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
# Created by https://www.gitignore.io/api/java,gradle,intellij+all
### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
### Intellij+all Patch ###
# Ignores the whole .idea folder and all .iml files
# See https://github.com/joeblau/gitignore.io/issues/186 and https://github.com/joeblau/gitignore.io/issues/360
.idea/
# Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-249601023
*.iml
modules.xml
.idea/misc.xml
*.ipr
### Java ###
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
### Gradle ###
.gradle
/build/
# Ignore Gradle GUI config
gradle-app.setting
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
# Cache of project
.gradletasknamecache
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties
# End of https://www.gitignore.io/api/java,gradle,intellij+all

31
build.gradle

@ -0,0 +1,31 @@ @@ -0,0 +1,31 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '2.0.4'
}
group 'com.phr00t'
version '1.7-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven { url "https://clojars.org/repo" }
}
dependencies {
implementation group: 'ddf.minim', name: 'ddf.minim', version: '2.2.0'
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
implementation group: 'net.sf.trove4j', name: 'trove4j', version: '3.0.3'
implementation group: 'org.jsoup', name: 'jsoup', version: '1.11.3'
}
jar {
manifest {
attributes "Main-Class": "com.phr00t.autostepper.AutoStepper"
}
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

5
gradle/wrapper/gradle-wrapper.properties vendored

@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

172
gradlew vendored

@ -0,0 +1,172 @@ @@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

1
lib/export.txt

@ -1 +0,0 @@ @@ -1 +0,0 @@
name = Minim Audio

BIN
lib/jl1.0.1.jar

Binary file not shown.

BIN
lib/jopt-simple-5.0.4.jar

Binary file not shown.

BIN
lib/jsminim.jar

Binary file not shown.

BIN
lib/jsoup-1.11.2.jar

Binary file not shown.

BIN
lib/mp3spi1.9.5.jar

Binary file not shown.

BIN
lib/tritonus_aos.jar

Binary file not shown.

BIN
lib/tritonus_share.jar

Binary file not shown.

BIN
lib/trove-3.0.3.jar

Binary file not shown.

82
src/ddf/minim/AudioBuffer.java

@ -1,82 +0,0 @@ @@ -1,82 +0,0 @@
/*
* Copyright (c) 2007 - 2009 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An <code>AudioBuffer</code> is a buffer of floating point samples
* corresponding to a single channel of streaming audio. It is readonly, but you
* can obtain a copy of the samples in the buffer by using the <code>toArray</code> method.
* In fact, when drawing a waveform, you should use the <code>toArray</code> method
* rather than iterating over the buffer itself because it is possible that the samples
* in the buffer will be replaced with new ones between calls to the <code>get</code> method,
* which results in a waveform that appears to have discontinuities in it.
*
* @author Damien Di Fede
*
*/
public interface AudioBuffer
{
/**
* Returns the length of the buffer.
*
* @return int: the number of samples in the buffer
*
* @related AudioBuffer
*/
int size();
/**
* Gets the <code>i<sup>th</sup></code> sample in the buffer. This method
* does not do bounds checking, so it may throw an exception.
*
* @param i
* int: the index of the sample you want to get
*
* @return float: the <code>i<sup>th</sup></code> sample
*
* @example Basics/DrawWaveformAndLevel
*
* @related AudioBuffer
*/
float get(int i);
/**
* Gets the current level of the buffer. It is calculated as the
* root-mean-square of all the samples in the buffer.
*
* @return float: the RMS amplitude of the buffer
*
* @example Basics/DrawWaveformAndLevel
*
* @related AudioBuffer
*/
float level();
/**
* Returns the samples in the buffer in a new float array.
* Modifying the samples in the returned array will not change
* the samples in the buffer.
*
* @return float[]: a new float array containing the buffer's samples
*
* @related AudioBuffer
*/
float[] toArray();
}

61
src/ddf/minim/AudioEffect.java

@ -1,61 +0,0 @@ @@ -1,61 +0,0 @@
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An <code>AudioEffect</code> is anything that can process one or two float
* arrays. Typically it is going to be some kind of time-based process because
* the float arrays passed to it will be consecutive chunks of audio data. The
* effect is expected to modify these arrays in such a way that the values
* remain in the range [-1, 1]. All of the effects included with Minim implement
* this interface and all you need to do to write your own effects is to create
* a class that implements this interface and then add an instance of it to an
* anything that is <code>Effectable</code>, such as an <code>AudioOutput</code>.
* <p>
* This interface is Deprecated and will likely be removed from a future version
* of Minim. We now recommend implementing your effects by extending <code>UGen</code>.
*
* @author Damien Di Fede
* @invisible
*
*/
@Deprecated
public interface AudioEffect
{
/**
* Processes <code>signal</code> in some way.
*
* @param signal
* an array of audio samples, representing a mono sound stream.
*/
void process(float[] signal);
/**
* Processes <code>sigLeft</code> and <code>sigRight</code> in some way.
*
* @param sigLeft
* an array of audio samples, representing the left channel of a
* stereo sound stream
* @param sigRight
* an array of audio samples, representing the right channel of a
* stereo sound stream
*/
void process(float[] sigLeft, float[] sigRight);
}

171
src/ddf/minim/AudioInput.java

@ -1,171 +0,0 @@ @@ -1,171 +0,0 @@
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
import ddf.minim.spi.AudioOut;
import ddf.minim.spi.AudioStream;
/**
* An AudioInput is a connection to the current record source of the computer.
* How the record source for a computer is set will depend on the soundcard and OS,
* but typically a user can open a control panel and set the source from there.
* Unfortunately, there is no way to set the record source from Java.
* <p>
* You can obtain an AudioInput from Minim by using one of the getLineIn methods:
* <pre>
* // get the default STEREO input
* AudioInput getLineIn()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioInput getLineIn(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the input you get back
* AudioInput getLineIn(int type, int bufferSize)
*
* // sampleRate is a request for an input of a certain sample rate
* AudioInput getLineIn(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an input with a certain bit depth
* AudioInput getLineIn(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* In the event that an input doesn't exist with the requested parameters,
* Minim will spit out an error and return null. In general,
* you will want to use the first two methods listed above.
*
* @example Basics/MonitorInput
*
* @related Minim
*
* @author Damien Di Fede
*
*/
public class AudioInput extends AudioSource
{
boolean m_isMonitoring;
AudioStream m_stream;
/** @invisible
*
* Constructs an <code>AudioInput</code> that uses <code>out</code> to read
* samples from <code>stream</code>. The samples from <code>stream</code>
* can be accessed by through the interface provided by <code>AudioSource</code>.
*
* @param stream the <code>AudioStream</code> that provides the samples
* @param out the <code>AudioOut</code> that will read from <code>stream</code>
*/
public AudioInput(AudioStream stream, AudioOut out)
{
super( out );
out.setAudioStream(stream);
stream.open();
disableMonitoring();
m_stream = stream;
}
public void close()
{
super.close();
m_stream.close();
}
/**
* Returns whether or not this AudioInput is monitoring.
* In other words, whether you will hear in your speakers
* the audio coming into the input.
*
* @return boolean: true if monitoring is on
*
* @example Basics/MonitorInput
*
* @related enableMonitoring ( )
* @related disableMonitoring ( )
* @related AudioInput
*/
public boolean isMonitoring()
{
return m_isMonitoring;
}
/**
* When monitoring is enabled, you will be able to hear
* the audio that is coming through the input.
*
* @example Basics/MonitorInput
*
* @related disableMonitoring ( )
* @related isMonitoring ( )
* @related AudioInput
*/
public void enableMonitoring()
{
// make sure we don't make sound
if ( hasControl(VOLUME) )
{
setVolume( 1 );
m_isMonitoring = true;
}
else if ( hasControl(GAIN) )
{
setGain( 0 );
m_isMonitoring = true;
}
else
{
Minim.error( "Monitoring is not available on this AudioInput." );
}
}
/**
*
* When monitoring is disabled, you will not hear
* the audio that is coming through the input,
* but you will still be able to access the samples
* in the left, right, and mix buffers. This is
* default state of an AudioInput and is what
* you will want if your input is microphone
* and your output is speakers. Otherwise: feedback.
*
* @shortdesc When monitoring is disabled, you will not hear
* the audio that is coming through the input.
*
* @example Basics/MonitorInput
*
* @related enableMonitoring ( )
* @related isMonitoring ( )
* @related AudioInput
*
*/
public void disableMonitoring()
{
// make sure we don't make sound
if ( hasControl(VOLUME) )
{
setVolume( 0 );
}
else if ( hasControl(GAIN) )
{
setGain( -64 );
}
m_isMonitoring = false;
}
}

72
src/ddf/minim/AudioListener.java

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* An <code>AudioListener</code> can be used to monitor <code>Recordable</code>
* objects such as <code>AudioPlayer</code>, <code>AudioOutput</code>, and <code>AudioInput</code>.
* Each time a <code>Recordable</code> object receives a new sample buffer
* from the audio system, or generates a new sample buffer at the request of the
* audio system, it passes a copy of this buffer to its listeners. You can
* implement this interface if you want to receive samples in a callback fashion,
* rather than using an object's <code>AudioBuffer</code>s to access them. You
* add an <code>AudioListener</code> to a <code>Recordable</code> by calling
* the addListener method. When you want to stop receiving samples you call the
* removeListener method.
*
* @example Advanced/AddAndRemoveAudioListener
*
* @author Damien Di Fede
*
* @related AudioPlayer
* @related AudioInput
* @related AudioOutput
* @related SignalSplitter
*/
public interface AudioListener
{
/**
* Called by the audio object this AudioListener is attached to
* when that object has new samples.
*
* @example Advanced/AddAndRemoveAudioListener
*
* @param samp
* a float[] buffer of samples from a MONO sound stream
*
* @related AudioListener
*/
void samples(float[] samp);
/**
* Called by the <code>Recordable</code> object this is attached to
* when that object has new samples.
*
* @param sampL
* a float[] buffer containing the left channel of a STEREO sound stream
* @param sampR
* a float[] buffer containing the right channel of a STEREO sound stream
*
* @related AudioListener
*/
void samples(float[] sampL, float[] sampR);
// TODO: consider replacing above two methods with this single one
// void samples( MultiChannelBuffer buffer );
}

243
src/ddf/minim/AudioMetaData.java

@ -1,243 +0,0 @@ @@ -1,243 +0,0 @@
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
/**
* <code>AudioMetaData</code> provides information commonly found in ID3 tags.
* However, other audio formats, such as Ogg, can contain
* similar information. So rather than refer to this information
* as ID3Tags or similar, we simply call it metadata. This base
* class returns the empty string or -1 from all methods and
* derived classes are expected to simply override the methods
* that they have information for. This is a little less brittle
* than using an interface because later on new properties can
* be added without breaking existing code.
*
* @example Basics/GetMetaData
*/
public abstract class AudioMetaData
{
/**
* The length of the recording in milliseconds.
*
* @return int: the length in milliseconds
*
* @related AudioMetaData
*/
public int length()
{
return -1;
}
/**
*
* How many sample frames are in this recording.
*
* @return int: the number of sample frames
*
* @related AudioMetaData
*/
public int sampleFrameCount()
{
return -1;
}
/**
* The name of the file / URL of the recording.
*
* @return String: the file name
*
* @related AudioMetaData
*/
public String fileName()
{
return "";
}
/**
* The title of the recording.
*
* @return String: the title tag
*
* @related AudioMetaData
*/
public String title()
{
return "";
}
/**
* The author of the recording.
*
* @return String: the author tag
*
* @related AudioMetaData
*/
public String author()
{
return "";
}
/**
* The album the recording came from.
*
* @return String: the album tab
*
* @related AudioMetaData
*/
public String album()
{
return "";
}
/**
* The date the recording was made.
*
* @return String: the date tag
*
* @related AudioMetaData
*/
public String date()
{
return "";
}
/**
* The comment field in the file.
*
* @return String: the comment tag
*
* @related AudioMetaData
*/
public String comment()
{
return "";
}
/**
* The track number of the recording.
* This will sometimes be in the form 3/10,
* giving you both the track number and total
* tracks on the album this track came from.
*
* @return String: the track tag
*
* @related AudioMetaData
*/
public String track()
{
return "";
}
/**
* The genre of the recording.
*
* @return String: the genre tag
*
* @related AudioMetaData
*/
public String genre()
{
return "";
}
/**
* The copyright of the recording.
*
* @return String: the copyright tag
*
* @related AudioMetaData
*/
public String copyright()
{
return "";
}
/**
* The disc number of the recording.
*
* @return String: the disc tag
*
* @related AudioMetaData
*/
public String disc()
{
return "";
}
/**
* The composer of the recording.
*
* @return String: the composer tag
*
* @related AudioMetaData
*/
public String composer()
{
return "";
}
/**
* The lyrics for the recording, if any.
*
* @return String: the lyrics tag
*
* @related AudioMetaData
*/
public String lyrics()
{
return "";
}
/**
* The orchestra that performed the recording.
*
* @return String: the orchestra tag
*
* @related AudioMetaData
*/
public String orchestra()
{
return "";
}
/**
* The publisher of the recording.
*
* @return String: the publisher tag
*
* @related AudioMetaData
*/
public String publisher()
{
return "";
}
/**
* The software the recording was encoded with.
*
* @return String: the encoded tag
*
* @related AudioMetaData
*/
public String encoded()
{
return "";
}
}

541
src/ddf/minim/AudioOutput.java

@ -1,541 +0,0 @@ @@ -1,541 +0,0 @@
/*
* Copyright (c) 2007 - 2008 by Damien Di Fede <ddf@compartmental.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package ddf.minim;
import ddf.minim.spi.AudioOut;
import ddf.minim.ugens.DefaultInstrument;
import ddf.minim.ugens.Frequency;
import ddf.minim.ugens.Instrument;
import ddf.minim.ugens.Summer;
/**
* <p>
* An AudioOutput is a connection to the output of a computer's sound card.
* Typically the computer speakers are connected to this.
* You can use an AudioOutput to do real-time sound synthesis by patching
* UGens to an output object. You can get an AudioOutput object from Minim
* using one of five methods:
* </p>
* <pre>
* AudioOutput getLineOut()
*
* // specifiy either Minim.MONO or Minim.STEREO for type
* AudioOutput getLineOut(int type)
*
* // bufferSize is the size of the left, right,
* // and mix buffers of the output you get back
* AudioOutput getLineOut(int type, int bufferSize)
*
* // sampleRate is a request for an output of a certain sample rate
* AudioOutput getLineOut(int type, int bufferSize, float sampleRate)
*
* // bitDepth is a request for an output with a certain bit depth
* AudioInput getLineOut(int type, int bufferSize, float sampleRate, int bitDepth)
* </pre>
* <p>
* In the event that an output doesn't exist with the requested parameters,
* Minim will spit out an error and return null.
* In general, you will want to use one of the first two methods listed above.
* </p>
* <p>
* In addition to directly patching UGens to the output, you can also schedule
* "notes" to be played by the output at some time in the future. This can
* be very powerful when writing algorithmic music and sound. See the playNote
* method for more information.
* </p>
*
* @author Damien Di Fede
* @related Minim
* @related UGen
* @related playNote ( )
*
* @example Basics/SynthesizeSound
* @example Basics/SequenceSound
*/
public class AudioOutput extends AudioSource implements Polyphonic
{
// the synth attach our signals to
private AudioOut synth;
// the signals added by the user
private SignalChain signals;
// the note manager for this output
private NoteManager noteManager;
// the Bus for UGens used by this output
Summer bus;
private class SampleGenerator implements AudioSignal
{
public void generate(float[] signal)
{
if ( signals.size() > 0 )
{
signals.generate( signal );
}
float[] tick = new float[1];
for ( int i = 0; i < signal.length; ++i )
{
noteManager.tick();
bus.tick( tick );
signal[i] += tick[0];
}
}
public void generate(float[] left, float[] right)
{
if ( signals.size() > 0 )
{
signals.generate( left, right );
}
float[] tick = new float[2];
for ( int i = 0; i < left.length; ++i )
{
noteManager.tick();
bus.tick( tick );
left[i] += tick[0];
right[i] += tick[1];
}
}
}
/**
* Constructs an <code>AudioOutput</code> that will use <code>out</code>
* to generate sound.
*
* @param out
* the <code>AudioOut</code> that does most of our work
*
* @invisible
*/
public AudioOutput(AudioOut out)
{
super( out );
synth = out;
signals = new SignalChain();
noteManager = new NoteManager( getFormat().getSampleRate() );
bus = new Summer();
// configure it
bus.setSampleRate( getFormat().getSampleRate() );
bus.setChannelCount( getFormat().getChannels() );
synth.setAudioSignal( new SampleGenerator() );
}
/** @deprecated */
public void addSignal(AudioSignal signal)
{
signals.add( signal );
}
/** @deprecated */
public AudioSignal getSignal(int i)
{
// get i+1 because the bus is signal 0.
return signals.get( i );
}
/** @deprecated */
public void removeSignal(AudioSignal signal)
{
signals.remove( signal );
}
/** @deprecated */
public AudioSignal removeSignal(int i)
{
// remove i+1 because the bus is 1
return signals.remove( i );
}
/** @deprecated */
public void clearSignals()
{
signals.clear();
}
/** @deprecated */
public void disableSignal(int i)
{
// disable i+1 because the bus is 0
signals.disable( i );
}
/** @deprecated */
public void disableSignal(AudioSignal signal)
{
signals.disable( signal );
}
/** @deprecated */
public void enableSignal(int i)
{
signals.enable( i );
}
/** @deprecated */
public void enableSignal(AudioSignal signal)
{
signals.enable( signal );
}
/** @deprecated */
public boolean isEnabled(AudioSignal signal)
{
return signals.isEnabled( signal );
}
/** @deprecated */
public boolean isSounding()
{
for ( int i = 1; i < signals.size(); i++ )
{
if ( signals.isEnabled( signals.get( i ) ) )
{
return true;
}
}
return false;
}
/** @deprecated */
public void noSound()
{
for ( int i = 1; i < signals.size(); i++ )
{
signals.disable( i );
}
}
/** @deprecated */
public int signalCount()
{
return signals.size();
}
/** @deprecated */
public void sound()
{
for ( int i = 1; i < signals.size(); i++ )
{
signals.enable( i );
}
}
/** @deprecated */
public boolean hasSignal(AudioSignal signal)
{
return signals.contains( signal );
}
/**
* playNote is a method of scheduling a "note" to be played at
* some time in the future (or immediately), where a "note" is
* an instance of a class that implements the Instrument interface.
* The Instrument interface requires you to implement a noteOn method
* that accepts a float duration value and is called when that
* Instrument should begin making sound, and a noteOff method
* that is called when that Instrument should stop making sound.
* <p>
* Versions of playNote that do not have an Instrument argument
* will create an instance of a default Instrument that plays a
* sine tone based on the parameters passed in.
* <p>
* To facilitate writing algorithmic music, the start time and
* duration of a note is expressed in <em>beats</em> and not in seconds.
* By default, the tempo of an AudioOutput will be 60 BPM (beats per minute),
* which means that beats are equivalent to seconds. If you want to think
* in seconds when writing your note playing code, then simply don't change
* the tempo of the output.
* <p>
* Another thing to keep in mind is that the AudioOutput processes its
* note queue in its own Thread, so if you are going to queue up a lot of
* notes at once you will want to use the pauseNotes method before queuing
* them. If you don't, the timing will be slightly off because the "now" that
* the start time of each note is an offset from will change from note to note.
* Once all of your notes have been added, you call resumeNotes to allow
* the AudioOutput to process notes again.
*
* @related Instrument
* @related setTempo ( )
* @related setNoteOffset ( )
* @related setDurationFactor ( )
* @related pauseNotes ( )
* @related resumeNotes ( )
*
* @example Basics/SequenceSound
*
* @shortdesc Schedule a "note" to played by the output.
*
* @param startTime
* float: when the note should begin playing, in beats
* @param duration
* float: how long the note should be, in beats
* @param instrument
* the Instrument that will play the note
*/
public void playNote(float startTime, float duration, Instrument instrument)
{
noteManager.addEvent( startTime, duration, instrument );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument.
*
* @see #playNote(float, float, Instrument)
*
* @param startTime
* float: when the note should begin playing, in beats
* @param duration
* float: how long the note should be, in beats
* @param hz
* float: the frequency, in Hertz, of the note to be played
*/
public void playNote(float startTime, float duration, float hz)
{
noteManager.addEvent( startTime, duration, new DefaultInstrument( hz, this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument.
*
* @see #playNote(float, float, Instrument)
*
* @param startTime
* float: when the note should begin playing, in beats
* @param duration
* float: how long the note should be, in beats
* @param pitchName
* String: the pitch name of the note to be played (e.g. "A4" or "Bb3")
*/
public void playNote(float startTime, float duration, String pitchName)
{
noteManager.addEvent( startTime, duration, new DefaultInstrument( Frequency.ofPitch( pitchName ).asHz(), this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument and has a duration of 1 beat.
*
* @see #playNote(float, float, Instrument)
*
* @param startTime
* float: when the note should begin playing, in beats
* @param hz
* float: the frequency, in Hertz, of the note to be played
*/
public void playNote(float startTime, float hz)
{
noteManager.addEvent( startTime, 1.0f, new DefaultInstrument( hz, this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument and has a duration of 1 beat.
*
* @see #playNote(float, float, Instrument)
*
* @param startTime
* float: when the note should begin playing, in beats
* @param pitchName
* String: the pitch name of the note to be played (e.g. "A4" or "Bb3")
*/
public void playNote(float startTime, String pitchName)
{
noteManager.addEvent( startTime, 1.0f, new DefaultInstrument( Frequency.ofPitch( pitchName ).asHz(), this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument, has a duration of 1 beat,
* and is played immediately.
*
* @see #playNote(float, float, Instrument)
*
* @param hz
* float: the frequency, in Hertz, of the note to be played
*/
public void playNote(float hz)
{
noteManager.addEvent( 0.0f, 1.0f, new DefaultInstrument( hz, this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument,
* has a duration of 1 beat, and is played immediately.
*
* @see #playNote(float, float, Instrument)
*
* @param pitchName
* String: the pitch name of the note to be played (e.g. "A4" or "Bb3")
*/
public void playNote(String pitchName)
{
noteManager.addEvent( 0.0f, 1.0f, new DefaultInstrument( Frequency.ofPitch( pitchName ).asHz(), this ) );
}
/**
* Schedule a "note" to played by the output that uses the default Instrument,
* has a duration of 1 beat, is played immediately, and has a pitch of "A4".
* This is good to use if you just want to generate some test tones.
*
* @see #playNote(float, float, Instrument)
*/
public void playNote()
{
noteManager.addEvent( 0.0f, 1.0f, new DefaultInstrument( Frequency.ofPitch( "" ).asHz(), this ) );
}
/**