cleanup (tentative) and get ready for merge

This commit is contained in:
Stefano D'Angelo 2024-02-05 13:55:57 +01:00
parent 2d3f850ca0
commit 152a33c65e
10 changed files with 272 additions and 280 deletions

View File

@ -101,7 +101,6 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
const float * in_buf = reinterpret_cast<const float *>(pInput); const float * in_buf = reinterpret_cast<const float *>(pInput);
float * out_buf = reinterpret_cast<float *>(pOutput); float * out_buf = reinterpret_cast<float *>(pOutput);
#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0
ma_uint32 i = 0; ma_uint32 i = 0;
#if NUM_CHANNELS_IN > 0 #if NUM_CHANNELS_IN > 0
size_t ix = 0; size_t ix = 0;
@ -128,14 +127,13 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
for (ma_uint32 j = 0; j < n; j++) for (ma_uint32 j = 0; j < n; j++)
for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++) for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++)
out_buf[iy] = y_buf[BLOCK_SIZE * k + j]; out_buf[iy] = y_buf[BLOCK_SIZE * k + j];
#elif NUM_CHANNELS_IN == 0
for (ma_uint32 j = 0; j < n; j++)
out_buf[j] = 0;
#endif #endif
i += n; i += n;
} }
#else
for (ma_uint32 i = 0; i < frameCount; i++)
out_buf[i] = 0.f; // Unique fake channel
#endif
} }
extern "C" extern "C"
@ -273,6 +271,7 @@ JNIEXPORT void JNICALL
JNI_FUNC(nativeAudioStop)(JNIEnv* env, jobject thiz) { JNI_FUNC(nativeAudioStop)(JNIEnv* env, jobject thiz) {
(void)env; (void)env;
(void)thiz; (void)thiz;
ma_device_stop(&device); ma_device_stop(&device);
ma_device_uninit(&device); ma_device_uninit(&device);
if (mem != NULL) if (mem != NULL)

View File

@ -1,35 +1,38 @@
include vars.mk include vars.mk
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) COMMON_DIR := $(or $(COMMON_DIR),.)
DATA_DIR := $(or $(DATA_DIR),.)
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
SOURCES := \
${DATA_DIR}/src/data.h \
${DATA_DIR}/src/index.html \
${COMMON_DIR}/src/app.swift \
${COMMON_DIR}/src/native.mm \
${COMMON_DIR}/src/app-Bridging-Header.h \
${PLUGIN_DIR}/plugin.h \
${C_SRCS_EXTRA} \
${CXX_SRCS_EXTRA}
SOURCES_OUT = $(addprefix build/gen/src/, $(notdir $(SOURCES)))
SOURCES := data.h index.html app.swift native.mm app-Bridging-Header.h platform.h plugin.h all: build/gen/${BUNDLE_NAME}.xcodeproj
SOURCES_IN := $(addprefix ${ROOT_DIR}/src/, ${SOURCES})
SOURCES_OUT := $(addprefix ${ROOT_DIR}/build/gen/src/, ${SOURCES})
EXT_SOURCES_IN := ${3RDPARTYFILES}
EXT_SOURCES_OUT :=
build/gen/${BUNDLE_NAME}.xcodeproj: ${SOURCES_OUT}
all: build/gen/${PROJECT_NAME}.xcodeproj
${SOURCES_OUT}: ${SOURCES_IN} ${EXT_SOURCES_IN} | build/gen/src
cp $^ ${ROOT_DIR}/build/gen/src
${EXT_SOURCES_OUT}: ${EXT_SOURCES_IN}
cp ${EXT_SOURCES_IN} ${ROOT_DIR}/build/gen/src/
build/gen/${PROJECT_NAME}.xcodeproj: ${SOURCES_OUT}
xcodegen generate --spec project.yml xcodegen generate --spec project.yml
mv ${PROJECT_NAME}.xcodeproj build/gen/${PROJECT_NAME}.xcodeproj mv ${BUNDLE_NAME}.xcodeproj build/gen/${BUNDLE_NAME}.xcodeproj
mv Info.plist build/gen/Info.plist mv Info.plist build/gen/Info.plist
build/gen build/gen/src: build/gen/src:
mkdir -p $@ mkdir -p $@
clean: clean:
rm -fr build rm -fr build
install: .PHONY: all clean
.PHONY: all clean install .SECONDEXPANSION:
PERCENT := %
$(SOURCES_OUT): build/gen/src/%: $$(filter $$(PERCENT)/%,$$(SOURCES)) | build/gen/src
cp $^ $@

View File

@ -1,6 +1,6 @@
name: {{=it.ios_make.projectName}} name: {{=it.product.bundleName}}
targets: targets:
{{=it.ios_make.targetName}}: {{=it.product.bundleName}}:
platform: [iOS] platform: [iOS]
deploymentTarget: deploymentTarget:
iOS: {{=it.ios_make.deploymentTarget}} iOS: {{=it.ios_make.deploymentTarget}}
@ -9,11 +9,15 @@ targets:
- path: src - path: src
settings: settings:
base: base:
PRODUCT_BUNDLE_IDENTIFIER: com.orastron.{{=it.product.bundleName}} PRODUCT_BUNDLE_IDENTIFIER: {{=it.ios_make.productBundleIdentifier}}
SWIFT_OBJC_BRIDGING_HEADER: src/app-Bridging-Header.h SWIFT_OBJC_BRIDGING_HEADER: src/app-Bridging-Header.h
HEADER_SEARCH_PATHS: {{~it.ios_make.header_search_paths:p}} {{?it.ios_make.headerSearchPaths}}
HEADER_SEARCH_PATHS: {{~it.ios_make.headerSearchPaths :p}}
- {{=p}}{{~}} - {{=p}}{{~}}
{{?}}
info: info:
path: Info.plist path: Info.plist
{{?it.product.buses.filter(x => x.type == "audio" && x.direction == "input").length > 0}}
properties: properties:
NSMicrophoneUsageDescription: Audio input access needed to run the example NSMicrophoneUsageDescription: Need audio input for processing sound
{{?}}

View File

@ -1,8 +1,8 @@
BUNDLE_NAME := {{=it.product.bundleName}} BUNDLE_NAME := {{=it.product.bundleName}}
PROJECT_NAME := {{=it.ios_make.projectName}} C_SRCS_EXTRA := {{=it.make && it.make.cSrcs ? it.make.cSrcs : ""}} {{=it.ios_make && it.ios_make.cSrcs ? it.ios_make.cSrcs : ""}}
TARGET_NAME := {{=it.ios_make.targetName}} CXX_SRCS_EXTRA := {{=it.make && it.make.cxxSrcs ? it.make.cxxSrcs : ""}} {{=it.ios_make && it.ios_make.cxxSrcs ? it.ios_make.cxxSrcs : ""}}
3RDPARTYFILES := {{=it.ios_make["3rdpartyfiles"].join(' ')}} COMMON_DIR := {{=it.ios_make && it.ios_make.commonDir ? it.ios_make.commonDir : (it.make && it.make.commonDir ? it.make.commonDir : "")}}
DATA_DIR := {{=it.ios_make && it.ios_make.dataDir ? it.ios_make.dataDir : (it.make && it.make.dataDir ? it.make.dataDir : "")}}
HAS_MIDI_IN := {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "input").length > 0 ? "yes" : "no"}} PLUGIN_DIR := {{=it.ios_make && it.ios_make.pluginDir ? it.ios_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}}

View File

@ -50,7 +50,7 @@ CFStringRef midiClientName = NULL;
MIDIClientRef midiClient = NULL; MIDIClientRef midiClient = NULL;
CFStringRef midiInputName = NULL; CFStringRef midiInputName = NULL;
MIDIPortRef midiPort = NULL; MIDIPortRef midiPort = NULL;
#define MIDIBUFFERLEN 1026 #define MIDIBUFFERLEN 1023
uint8_t midiBuffer[MIDIBUFFERLEN]; uint8_t midiBuffer[MIDIBUFFERLEN];
int midiBuffer_i = 0; int midiBuffer_i = 0;
#endif #endif
@ -89,40 +89,39 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput,
const float * in_buf = reinterpret_cast<const float *>(pInput); const float * in_buf = reinterpret_cast<const float *>(pInput);
#endif #endif
float * out_buf = reinterpret_cast<float *>(pOutput); float * out_buf = reinterpret_cast<float *>(pOutput);
#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0
ma_uint32 i = 0; ma_uint32 i = 0;
#if NUM_CHANNELS_IN > 0 #if NUM_CHANNELS_IN > 0
size_t ix = 0; size_t ix = 0;
#endif #endif
#if NUM_CHANNELS_OUT > 0 #if NUM_CHANNELS_OUT > 0
size_t iy = 0; size_t iy = 0;
#endif #endif
while (i < frameCount) { while (i < frameCount) {
ma_uint32 n = std::min(frameCount - i, static_cast<ma_uint32>(BLOCK_SIZE)); ma_uint32 n = std::min(frameCount - i, static_cast<ma_uint32>(BLOCK_SIZE));
#if NUM_CHANNELS_IN > 0 #if NUM_CHANNELS_IN > 0
for (ma_uint32 j = 0; j < n; j++) for (ma_uint32 j = 0; j < n; j++)
for (size_t k = 0; k < NUM_CHANNELS_IN; k++, ix++) for (size_t k = 0; k < NUM_CHANNELS_IN; k++, ix++)
x_buf[BLOCK_SIZE * k + j] = in_buf[ix]; x_buf[BLOCK_SIZE * k + j] = in_buf[ix];
#endif #endif
#if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN #if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN
memset(zero, 0, BLOCK_SIZE * sizeof(float)); memset(zero, 0, BLOCK_SIZE * sizeof(float));
#endif #endif
plugin_process(&instance, x, y, n); plugin_process(&instance, x, y, n);
#if NUM_CHANNELS_OUT > 0 #if NUM_CHANNELS_OUT > 0
for (ma_uint32 j = 0; j < n; j++) for (ma_uint32 j = 0; j < n; j++)
for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++) for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++)
out_buf[iy] = y_buf[BLOCK_SIZE * k + j]; out_buf[iy] = y_buf[BLOCK_SIZE * k + j];
#endif #elif NUM_CHANNELS_IN == 0
for (ma_uint32 j = 0; j < n; j++)
out_buf[j] = 0.f;
#endif
i += n; i += n;
} }
#else
for (ma_uint32 i = 0; i < frameCount; i++)
out_buf[i] = 0.f; // Unique fake channel
#endif
} }
#if (NUM_MIDI_INPUTS > 0) #if (NUM_MIDI_INPUTS > 0)
@ -161,7 +160,6 @@ void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(
extern "C" extern "C"
char audioStart() { char audioStart() {
#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0
# if NUM_CHANNELS_IN == 0 # if NUM_CHANNELS_IN == 0
ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback); ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback);
@ -332,6 +330,7 @@ float getParameter(int i) {
mutex.unlock(); mutex.unlock();
return v; return v;
#else #else
(void)i;
return 0.f; return 0.f;
#endif #endif
} }

View File

@ -1,6 +0,0 @@
#ifndef PLATFORM_H
#define PLATFORM_H
#define NDEBUG
#endif

View File

@ -3,9 +3,8 @@ var sep = path.sep;
module.exports = function (data, api) { module.exports = function (data, api) {
api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data); api.generateFileFromTemplateFile(`src${sep}data.h`, `src${sep}data.h`, data);
api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data);
api.copyFile(`src${sep}native.mm`, `src${sep}native.mm`); api.copyFile(`src${sep}native.mm`, `src${sep}native.mm`);
api.copyFile(`src${sep}app-Bridging-Header.h`, `src${sep}app-Bridging-Header.h`); api.copyFile(`src${sep}app-Bridging-Header.h`, `src${sep}app-Bridging-Header.h`);
api.copyFile(`src${sep}platform.h`, `src${sep}platform.h`); api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`, data);
api.generateFileFromTemplateFile(`src${sep}app.swift`, `src${sep}app.swift`, data);
api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data);
}; };

View File

@ -1,11 +1,8 @@
{ {
"ios_make": { "ios_make": {
"header_search_paths": [], "headerSearchPaths": [],
"3rdpartyfiles": [ "sourcesExtra": [],
"../../../miniaudio/miniaudio.h" "productBundleIdentifier": "com.example.tibia_test",
],
"projectName": "tibia_test",
"targetName": "tibia_test",
"deploymentTarget": 16.6 "deploymentTarget": 16.6
} }
} }

View File

@ -1,3 +0,0 @@
{
}

View File

@ -19,8 +19,8 @@ $dir/../tibia $dir/product.json,$dir/company.json,$dir/android.json,$dir/android
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
$dir/../tibia $dir/product.json,$dir/company.json,$dir/ios.json $dir/../templates/ios $dir/../out/ios $dir/../tibia $dir/product.json,$dir/company.json $dir/../templates/ios $dir/../out/ios
$dir/../tibia $dir/product.json,$dir/company.json,$dir/ios.json,$dir/ios-make.json $dir/../templates/ios-make $dir/../out/ios $dir/../tibia $dir/product.json,$dir/company.json,$dir/ios-make.json $dir/../templates/ios-make $dir/../out/ios
cp $dir/plugin.h $dir/../out/ios/src cp $dir/plugin.h $dir/../out/ios/src
$dir/../tibia $dir/product.json,$dir/company.json,$dir/cmd.json $dir/../templates/cmd $dir/../out/cmd $dir/../tibia $dir/product.json,$dir/company.json,$dir/cmd.json $dir/../templates/cmd $dir/../out/cmd