cpumeter android
This commit is contained in:
parent
af99a702c3
commit
1587e1ec9f
@ -80,6 +80,11 @@ static struct {
|
|||||||
},
|
},
|
||||||
{{~}}
|
{{~}}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
{{?it.product.parameters.find(x => x.direction == "output" && x.isCpumeter)}}
|
||||||
|
# define PARAM_OUT_CPU_INDEX {{=it.product.parameters.indexOf(it.product.parameters.find(x => x.direction == "output" && x.isCpumeter))}}
|
||||||
|
{{?}}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define JNI_FUNC(x) Java_{{=it.android.javaPackageName.replaceAll("_", "_1").replaceAll(".", "_")}}_MainActivity_##x
|
#define JNI_FUNC(x) Java_{{=it.android.javaPackageName.replaceAll("_", "_1").replaceAll(".", "_")}}_MainActivity_##x
|
||||||
|
@ -52,10 +52,13 @@ typedef struct {
|
|||||||
|
|
||||||
#if NUM_MIDI_INPUTS > 0
|
#if NUM_MIDI_INPUTS > 0
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
|
||||||
# include <amidi/AMidi.h>
|
# include <amidi/AMidi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
# include "fatica.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__i386__) || defined(__x86_64__)
|
#if defined(__i386__) || defined(__x86_64__)
|
||||||
#include <xmmintrin.h>
|
#include <xmmintrin.h>
|
||||||
#include <pmmintrin.h>
|
#include <pmmintrin.h>
|
||||||
@ -102,10 +105,18 @@ std::vector<PortData> midiPorts;
|
|||||||
# define MIDI_BUFFER_SIZE 1024
|
# define MIDI_BUFFER_SIZE 1024
|
||||||
uint8_t midiBuffer[MIDI_BUFFER_SIZE];
|
uint8_t midiBuffer[MIDI_BUFFER_SIZE];
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
float cpu_meter = 0.f;
|
||||||
|
float sample_rate = 1.f;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
|
static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) {
|
||||||
(void)pDevice;
|
(void)pDevice;
|
||||||
|
|
||||||
|
#ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
const unsigned long long processTimeStart = fatica_time_process();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__aarch64__)
|
#if defined(__aarch64__)
|
||||||
uint64_t fpcr;
|
uint64_t fpcr;
|
||||||
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
__asm__ __volatile__ ("mrs %0, fpcr" : "=r"(fpcr));
|
||||||
@ -122,8 +133,15 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
|
|||||||
if (mutex.try_lock()) {
|
if (mutex.try_lock()) {
|
||||||
# if PARAMETERS_N > 0
|
# if PARAMETERS_N > 0
|
||||||
for (size_t i = 0; i < PARAMETERS_N; i++) {
|
for (size_t i = 0; i < PARAMETERS_N; i++) {
|
||||||
if (param_data[i].out)
|
if (param_data[i].out) {
|
||||||
|
# ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
if (i == PARAM_OUT_CPU_INDEX) {
|
||||||
|
param_values_prev[i] = param_values[i] = cpu_meter;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
|
param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i);
|
||||||
|
}
|
||||||
else if (param_values_prev[i] != param_values[i]) {
|
else if (param_values_prev[i] != param_values[i]) {
|
||||||
plugin_set_parameter(&instance, i, param_values[i]);
|
plugin_set_parameter(&instance, i, param_values[i]);
|
||||||
param_values_prev[i] = param_values[i];
|
param_values_prev[i] = param_values[i];
|
||||||
@ -188,6 +206,13 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
|
|||||||
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
_MM_SET_FLUSH_ZERO_MODE(flush_zero_mode);
|
||||||
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
_MM_SET_DENORMALS_ZERO_MODE(denormals_zero_mode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
const unsigned long long processTimeEnd = fatica_time_process();
|
||||||
|
const unsigned long long processTime100n = processTimeEnd - processTimeStart;
|
||||||
|
const double processTimeS = ((double) processTime100n) * 1.0e-7;
|
||||||
|
cpu_meter = cpu_meter * 0.9f + ((float) (processTimeS * sample_rate)) * 0.1f;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
@ -249,6 +274,10 @@ JNI_FUNC(nativeAudioStart)(JNIEnv* env, jobject thiz) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
plugin_set_sample_rate(&instance, (float)device.sampleRate);
|
plugin_set_sample_rate(&instance, (float)device.sampleRate);
|
||||||
|
#ifdef PARAM_OUT_CPU_INDEX
|
||||||
|
sample_rate = (float)device.sampleRate;
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t req = plugin_mem_req(&instance);
|
size_t req = plugin_mem_req(&instance);
|
||||||
if (req != 0) {
|
if (req != 0) {
|
||||||
mem = malloc(req);
|
mem = malloc(req);
|
||||||
|
@ -18,6 +18,7 @@ cp $dir/plugin.h $dir/../out/web/src
|
|||||||
|
|
||||||
$dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json $dir/../templates/android $dir/../out/android
|
$dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json $dir/../templates/android $dir/../out/android
|
||||||
$dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json,$dir/android-make.json $dir/../templates/android-make $dir/../out/android
|
$dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json,$dir/android-make.json $dir/../templates/android-make $dir/../out/android
|
||||||
|
cp $dir/../templates/common/* $dir/../out/android/src/
|
||||||
cp $dir/keystore.jks $dir/../out/android
|
cp $dir/keystore.jks $dir/../out/android
|
||||||
cp $dir/plugin.h $dir/../out/android/src
|
cp $dir/plugin.h $dir/../out/android/src
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user