Beatmup
wrapper_audio.cpp File Reference
#include "wrapper.h"
#include "include/Beatmup_Audio_Signal.h"
#include "include/Beatmup_Audio_SignalPlot.h"
#include "include/Beatmup_Audio_Playback.h"
#include "include/Beatmup_Audio_HarmonicSource.h"
#include <core/audio/playback/android/sles_playback.h>
#include <core/audio/signal.h>
#include <core/audio/signal_plot.h>
#include <core/color/packing.h>

Go to the source code of this file.

Functions

 BEATMUP_OBJ (Beatmup::Context, ctx, jCtx)
 
 return (JNIEnv *jenv, jclass, jobject jCtx, jstring jsFilename)
 
 BEATMUP_OBJ (Beatmup::Audio::Signal, signal, handle)
 
 return (JNIEnv *jenv, jclass, jlong handle)
 
 return (jint) signal -> getSampleFormat()
 
return signal getChannelCount ()
 
 BEATMUP_OBJ (Beatmup::Audio::SignalPlot, plot, hPlot)
 
 BEATMUP_OBJ (Beatmup::Audio::Signal, signal, hSignal)
 
plot setSignal (signal)
 
 BEATMUP_OBJ (Beatmup::AbstractBitmap, bitmap, jBitmap)
 
plot setBitmap (bitmap)
 
plot setWindow (Beatmup::IntRectangle(t1, y1, t2, y2), scale)
 
plot setPlotArea (Beatmup::IntRectangle(x1, y1, x2, y2))
 
plot setPalette (Beatmup::fromPackedInt((int32_t) background), Beatmup::fromPackedInt((int32_t) color1), Beatmup::fromPackedInt((int32_t) color2))
 
plot setChannels (channels)
 
 return (JNIEnv *jenv, jobject, jlong handle, jint sampleRate, jint sampleFormat, jint numChannels, jint bufferLength, jint numBuffers)
 
 JNIMETHOD (void, start, Java_Beatmup_Audio_Playback, start)(JNIEnv *jenv
 
 BEATMUP_OBJ (Beatmup::Audio::BasicRealtimePlayback, pb, handle)
 
 catch (Beatmup::Audio::PlaybackException &pex)
 
 JNIMETHOD (void, stop, Java_Beatmup_Audio_Playback, stop)(JNIEnv *jenv
 
 BEATMUP_OBJ (Beatmup::Audio::AbstractPlayback, pb, handle)
 
 BEATMUP_OBJ (Beatmup::Audio::Source, source, jSource)
 
pb setSource (source)
 
 return (JNIEnv *jenv, jobject, jlong handle, jfloat hz)
 
 BEATMUP_OBJ (Beatmup::Audio::HarmonicSource, source, handle)
 
source setPhase (rad)
 
source setAmplitude (amp)
 

Variables

JNIEnv * jenv
 
JNIEnv jclass
 
JNIEnv jobject jCtx
 
JNIEnv jobject jint format
 
JNIEnv jobject jint jint samplerate
 
JNIEnv jobject jint jint jint channels
 
JNIEnv jobject jint jint jint jfloat fragment
 
JNIEnv jobject jlong handle
 
JNIEnv jobject
 
JNIEnv jlong hPlot
 
JNIEnv jlong jlong hSignal
 
JNIEnv jlong jobject jBitmap
 
JNIEnv jlong jint t1
 
JNIEnv jlong jint jint t2
 
JNIEnv jlong jint jint jint y1
 
JNIEnv jlong jint jint jint jint y2
 
JNIEnv jlong jint jint jint jint jfloat scale
 
JNIEnv jlong jint x1
 
JNIEnv jlong jint jint jint x2
 
JNIEnv jlong jint background
 
JNIEnv jlong jint jint color1
 
JNIEnv jlong jint jint jint color2
 
 try
 
JNIEnv jlong jobject jSource
 
JNIEnv jlong jfloat rad
 
JNIEnv jlong jfloat amp
 

Function Documentation

◆ BEATMUP_OBJ() [1/9]

BEATMUP_OBJ ( Beatmup::Context  ,
ctx  ,
jCtx   
)

◆ return() [1/5]

return ( JNIEnv *  jenv,
jclass  ,
jobject  jCtx,
jstring  jsFilename 
)
new

Definition at line 40 of file wrapper_audio.cpp.

46 {
47  // copy filename first
48  const char* javaChar = jenv->GetStringUTFChars(jsFilename, 0);
49  std::string filename(javaChar);
50  jenv->ReleaseStringUTFChars(jsFilename, javaChar);
51  // do the stuff then
54  try {
56  }
57  catch (Beatmup::Exception& ex) { $pool.throwToJava(jenv, "java/io/IOError", ex.what()); }
59 }
static void throwToJava(JNIEnv *jenv, const char *exceptionClass, const char *message)
Throws a specific exception.
Definition: objectpool.h:156
static const jlong INVALID_HANDLE
Definition: objectpool.h:61
static Signal * loadWAV(Context &ctx, const char *fileName)
Definition: signal.cpp:64
Basic class: task and memory management, any kind of static data.
Definition: context.h:59
Base class for all exceptions.
Definition: exception.h:37
virtual const char * what() const NOEXCEPT override
Definition: exception.h:56
#define BEATMUP_ENTER
Definition: wrapper.h:35
BeatmupJavaObjectPool $pool
JNIEnv jobject jCtx
JNIEnv * jenv
BEATMUP_OBJ(Beatmup::Context, ctx, jCtx)
return() jlong(listener)
Beatmup::Context * ctx
JNIEnv jlong jstring filename
const char * javaChar

◆ BEATMUP_OBJ() [2/9]

BEATMUP_OBJ ( Beatmup::Audio::Signal  ,
signal  ,
handle   
)

◆ return() [2/5]

return ( JNIEnv *  jenv,
jclass  ,
jlong  handle 
)
new

Definition at line 67 of file wrapper_audio.cpp.

73 {
76  return (jint)signal->getDuration();
77 }
An audio signal.
Definition: signal.h:36
JNIEnv jobject jlong handle

◆ return() [3/5]

return ( jint  ) -> getSampleFormat()

◆ getChannelCount()

return signal getChannelCount ( )

◆ BEATMUP_OBJ() [3/9]

BEATMUP_OBJ ( Beatmup::Audio::SignalPlot  ,
plot  ,
hPlot   
)

◆ BEATMUP_OBJ() [4/9]

BEATMUP_OBJ ( Beatmup::Audio::Signal  ,
signal  ,
hSignal   
)

◆ setSignal()

plot setSignal ( signal  )

◆ BEATMUP_OBJ() [5/9]

BEATMUP_OBJ ( Beatmup::AbstractBitmap  ,
bitmap  ,
jBitmap   
)

◆ setBitmap()

plot setBitmap ( bitmap  )

◆ setWindow()

plot setWindow ( Beatmup::IntRectangle(t1, y1, t2, y2 ,
scale   
)

◆ setPlotArea()

plot setPlotArea ( Beatmup::IntRectangle(x1, y1, x2, y2 )

◆ setPalette()

plot setPalette ( Beatmup::fromPackedInt((int32_t) background ,
Beatmup::fromPackedInt((int32_t) color1 ,
Beatmup::fromPackedInt((int32_t) color2  
)

◆ setChannels()

plot setChannels ( channels  )

◆ return() [4/5]

return ( JNIEnv *  jenv,
jobject  ,
jlong  handle,
jint  sampleRate,
jint  sampleFormat,
jint  numChannels,
jint  bufferLength,
jint  numBuffers 
)
new

Definition at line 187 of file wrapper_audio.cpp.

193 {
196  try {
198  sampleRate, (Beatmup::AudioSampleFormat)sampleFormat, numChannels, bufferLength, numBuffers
199  ));
200  }
201  catch (Beatmup::Audio::PlaybackException& pex) { $pool.throwToJava(jenv, "Beatmup/Exceptions/PlaybackException", pex.what()); }
202 }
Abstract audio playback base class.
Communicates an error occurred during the playback.
AudioSampleFormat
Format of audio samples.

◆ JNIMETHOD() [1/2]

JNIMETHOD ( void  ,
start  ,
Java_Beatmup_Audio_Playback  ,
start   
)

◆ BEATMUP_OBJ() [6/9]

BEATMUP_OBJ ( Beatmup::Audio::BasicRealtimePlayback  ,
pb  ,
handle   
)

◆ catch()

Definition at line 211 of file wrapper_audio.cpp.

211 { $pool.throwToJava(jenv, "Beatmup/Exceptions/PlaybackException", pex.what()); }

◆ JNIMETHOD() [2/2]

JNIMETHOD ( void  ,
stop  ,
Java_Beatmup_Audio_Playback  ,
stop   
)

◆ BEATMUP_OBJ() [7/9]

BEATMUP_OBJ ( Beatmup::Audio::AbstractPlayback  ,
pb  ,
handle   
)

◆ BEATMUP_OBJ() [8/9]

BEATMUP_OBJ ( Beatmup::Audio::Source  ,
source  ,
jSource   
)

◆ setSource()

pb setSource ( source  )

◆ return() [5/5]

return ( JNIEnv *  jenv,
jobject  ,
jlong  handle,
jfloat  hz 
)
new

Definition at line 242 of file wrapper_audio.cpp.

247 {
250  source->setFrequency(hz);
251 }
A Source producing a sinusoidal signal, mainly for test purposes.
Definition: source.h:86

◆ BEATMUP_OBJ() [9/9]

BEATMUP_OBJ ( Beatmup::Audio::HarmonicSource  ,
source  ,
handle   
)

◆ setPhase()

source setPhase ( rad  )

◆ setAmplitude()

source setAmplitude ( amp  )

Variable Documentation

◆ jenv

JNIEnv * jenv

Definition at line 36 of file wrapper_audio.cpp.

◆ jclass

JNIEnv jclass
Initial value:

Definition at line 36 of file wrapper_audio.cpp.

◆ jCtx

jobject jCtx
Initial value:

Definition at line 36 of file wrapper_audio.cpp.

◆ format

JNIEnv jobject jint format

Definition at line 36 of file wrapper_audio.cpp.

◆ samplerate

JNIEnv jobject jint jint samplerate

Definition at line 36 of file wrapper_audio.cpp.

◆ channels

JNIEnv jlong jint channels
Initial value:

Definition at line 36 of file wrapper_audio.cpp.

◆ fragment

JNIEnv jobject jint jint jint jfloat fragment
Initial value:

Definition at line 36 of file wrapper_audio.cpp.

◆ handle

JNIEnv jlong handle
Initial value:

Definition at line 63 of file wrapper_audio.cpp.

◆ jobject

JNIEnv jobject

Definition at line 120 of file wrapper_audio.cpp.

◆ hPlot

JNIEnv jlong hPlot

Definition at line 120 of file wrapper_audio.cpp.

◆ hSignal

JNIEnv jlong jlong hSignal
Initial value:

Definition at line 120 of file wrapper_audio.cpp.

◆ jBitmap

JNIEnv jlong jobject jBitmap
Initial value:

Definition at line 131 of file wrapper_audio.cpp.

◆ t1

JNIEnv jlong jint t1

Definition at line 141 of file wrapper_audio.cpp.

◆ t2

JNIEnv jlong jint jint t2

Definition at line 141 of file wrapper_audio.cpp.

◆ y1

JNIEnv jlong jint jint y1

Definition at line 141 of file wrapper_audio.cpp.

◆ y2

JNIEnv jlong jint jint jint jint y2
Initial value:

Definition at line 141 of file wrapper_audio.cpp.

◆ scale

JNIEnv jlong jint jint jint jint jfloat scale
Initial value:

Definition at line 141 of file wrapper_audio.cpp.

◆ x1

JNIEnv jlong jint x1

Definition at line 150 of file wrapper_audio.cpp.

◆ x2

JNIEnv jlong jint jint jint x2

Definition at line 150 of file wrapper_audio.cpp.

◆ background

JNIEnv jlong jint background

Definition at line 159 of file wrapper_audio.cpp.

◆ color1

JNIEnv jlong jint jint color1

Definition at line 159 of file wrapper_audio.cpp.

◆ color2

JNIEnv jlong jint jint jint color2
Initial value:

Definition at line 159 of file wrapper_audio.cpp.

◆ try

try
Initial value:
{
pb->start()

Definition at line 208 of file wrapper_audio.cpp.

◆ jSource

JNIEnv jlong jobject jSource
Initial value:

Definition at line 226 of file wrapper_audio.cpp.

◆ rad

JNIEnv jlong jfloat rad
Initial value:

Definition at line 254 of file wrapper_audio.cpp.

◆ amp

JNIEnv jlong jfloat amp
Initial value:

Definition at line 262 of file wrapper_audio.cpp.