diff --git a/templates/android/src/jni.cpp b/templates/android/src/jni.cpp index cde4110..6f099c6 100644 --- a/templates/android/src/jni.cpp +++ b/templates/android/src/jni.cpp @@ -101,7 +101,6 @@ static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, const float * in_buf = reinterpret_cast(pInput); float * out_buf = reinterpret_cast(pOutput); -#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 ma_uint32 i = 0; #if NUM_CHANNELS_IN > 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 (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++) 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 i += n; } -#else - for (ma_uint32 i = 0; i < frameCount; i++) - out_buf[i] = 0.f; // Unique fake channel -#endif } extern "C" @@ -146,14 +144,14 @@ JNI_FUNC(nativeAudioStart)(JNIEnv* env, jobject thiz) { #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 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); # elif NUM_CHANNELS_OUT == 0 - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_capture); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_capture); # else - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_duplex); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_duplex); # endif #else - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback); #endif deviceConfig.periodSizeInFrames = BLOCK_SIZE; @@ -171,9 +169,9 @@ JNI_FUNC(nativeAudioStart)(JNIEnv* env, jobject thiz) { deviceConfig.playback.pDeviceID = NULL; deviceConfig.playback.format = ma_format_f32; #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 - deviceConfig.playback.channels = NUM_CHANNELS_OUT; + deviceConfig.playback.channels = NUM_CHANNELS_OUT; #else - deviceConfig.playback.channels = 1; // Fake & muted + deviceConfig.playback.channels = 1; // Fake & muted #endif deviceConfig.playback.shareMode = ma_share_mode_shared; @@ -273,6 +271,7 @@ JNIEXPORT void JNICALL JNI_FUNC(nativeAudioStop)(JNIEnv* env, jobject thiz) { (void)env; (void)thiz; + ma_device_stop(&device); ma_device_uninit(&device); if (mem != NULL) diff --git a/templates/ios-make/Makefile b/templates/ios-make/Makefile index 561bbe0..84d1ffa 100644 --- a/templates/ios-make/Makefile +++ b/templates/ios-make/Makefile @@ -1,35 +1,38 @@ 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 -SOURCES_IN := $(addprefix ${ROOT_DIR}/src/, ${SOURCES}) -SOURCES_OUT := $(addprefix ${ROOT_DIR}/build/gen/src/, ${SOURCES}) -EXT_SOURCES_IN := ${3RDPARTYFILES} -EXT_SOURCES_OUT := +all: build/gen/${BUNDLE_NAME}.xcodeproj - - -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} +build/gen/${BUNDLE_NAME}.xcodeproj: ${SOURCES_OUT} 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 -build/gen build/gen/src: +build/gen/src: mkdir -p $@ clean: 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 $^ $@ diff --git a/templates/ios-make/project.yml b/templates/ios-make/project.yml index a41fd14..d4975ac 100644 --- a/templates/ios-make/project.yml +++ b/templates/ios-make/project.yml @@ -1,6 +1,6 @@ -name: {{=it.ios_make.projectName}} +name: {{=it.product.bundleName}} targets: - {{=it.ios_make.targetName}}: + {{=it.product.bundleName}}: platform: [iOS] deploymentTarget: iOS: {{=it.ios_make.deploymentTarget}} @@ -9,11 +9,15 @@ targets: - path: src settings: 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 - HEADER_SEARCH_PATHS: {{~it.ios_make.header_search_paths:p}} +{{?it.ios_make.headerSearchPaths}} + HEADER_SEARCH_PATHS: {{~it.ios_make.headerSearchPaths :p}} - {{=p}}{{~}} +{{?}} info: path: Info.plist +{{?it.product.buses.filter(x => x.type == "audio" && x.direction == "input").length > 0}} properties: - NSMicrophoneUsageDescription: Audio input access needed to run the example + NSMicrophoneUsageDescription: Need audio input for processing sound +{{?}} diff --git a/templates/ios-make/vars.mk b/templates/ios-make/vars.mk index fdc94b9..470a7aa 100644 --- a/templates/ios-make/vars.mk +++ b/templates/ios-make/vars.mk @@ -1,8 +1,8 @@ BUNDLE_NAME := {{=it.product.bundleName}} -PROJECT_NAME := {{=it.ios_make.projectName}} -TARGET_NAME := {{=it.ios_make.targetName}} +C_SRCS_EXTRA := {{=it.make && it.make.cSrcs ? it.make.cSrcs : ""}} {{=it.ios_make && it.ios_make.cSrcs ? it.ios_make.cSrcs : ""}} +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(' ')}} - -HAS_MIDI_IN := {{=it.product.buses.filter(x => x.type == "midi" && x.direction == "input").length > 0 ? "yes" : "no"}} +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 : "")}} +PLUGIN_DIR := {{=it.ios_make && it.ios_make.pluginDir ? it.ios_make.pluginDir : (it.make && it.make.pluginDir ? it.make.pluginDir : "")}} diff --git a/templates/ios/src/native.mm b/templates/ios/src/native.mm index 2c95b76..b9646c4 100644 --- a/templates/ios/src/native.mm +++ b/templates/ios/src/native.mm @@ -16,7 +16,7 @@ #include "miniaudio.h" #define BLOCK_SIZE 32 -#define NUM_BUFS (NUM_CHANNELS_IN > NUM_CHANNELS_OUT ? NUM_CHANNELS_IN : NUM_CHANNELS_OUT) +#define NUM_BUFS (NUM_CHANNELS_IN > NUM_CHANNELS_OUT ? NUM_CHANNELS_IN : NUM_CHANNELS_OUT) static ma_device device; static plugin instance; @@ -50,302 +50,301 @@ CFStringRef midiClientName = NULL; MIDIClientRef midiClient = NULL; CFStringRef midiInputName = NULL; MIDIPortRef midiPort = NULL; -#define MIDIBUFFERLEN 1026 +#define MIDIBUFFERLEN 1023 uint8_t midiBuffer[MIDIBUFFERLEN]; int midiBuffer_i = 0; #endif static void data_callback(ma_device* pDevice, void* pOutput, const void* pInput, ma_uint32 frameCount) { - (void)pDevice; - + (void)pDevice; + #if PARAMETERS_N + NUM_MIDI_INPUTS > 0 - if (mutex.try_lock()) { + if (mutex.try_lock()) { # if PARAMETERS_N > 0 - for (size_t i = 0; i < PARAMETERS_N; i++) { - if (param_data[i].out) - param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i); - else if (param_values_prev[i] != param_values[i]) { - plugin_set_parameter(&instance, i, param_values[i]); - param_values_prev[i] = param_values[i]; - } - } + for (size_t i = 0; i < PARAMETERS_N; i++) { + if (param_data[i].out) + param_values_prev[i] = param_values[i] = plugin_get_parameter(&instance, i); + else if (param_values_prev[i] != param_values[i]) { + plugin_set_parameter(&instance, i, param_values[i]); + param_values_prev[i] = param_values[i]; + } + } # endif # if NUM_MIDI_INPUTS > 0 - if (midiBuffer_i > 0) { - for (int i = 0; i < midiBuffer_i; i+=3) { - plugin_midi_msg_in(&instance, MIDI_BUS_IN, &(midiBuffer[i])); - } - } - midiBuffer_i = 0; + if (midiBuffer_i > 0) { + for (int i = 0; i < midiBuffer_i; i+=3) { + plugin_midi_msg_in(&instance, MIDI_BUS_IN, &(midiBuffer[i])); + } + } + midiBuffer_i = 0; # endif - mutex.unlock(); - } + mutex.unlock(); + } #endif - + #if NUM_CHANNELS_IN == 0 - (void)pInput; + (void)pInput; #else - const float * in_buf = reinterpret_cast(pInput); + const float * in_buf = reinterpret_cast(pInput); #endif - float * out_buf = reinterpret_cast(pOutput); -#if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 - ma_uint32 i = 0; - #if NUM_CHANNELS_IN > 0 - size_t ix = 0; - #endif - #if NUM_CHANNELS_OUT > 0 - size_t iy = 0; - #endif - - while (i < frameCount) { - ma_uint32 n = std::min(frameCount - i, static_cast(BLOCK_SIZE)); - - #if NUM_CHANNELS_IN > 0 - for (ma_uint32 j = 0; j < n; j++) - for (size_t k = 0; k < NUM_CHANNELS_IN; k++, ix++) - x_buf[BLOCK_SIZE * k + j] = in_buf[ix]; - #endif - - #if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN - memset(zero, 0, BLOCK_SIZE * sizeof(float)); - #endif - plugin_process(&instance, x, y, n); - - #if NUM_CHANNELS_OUT > 0 - for (ma_uint32 j = 0; j < n; j++) - for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++) - out_buf[iy] = y_buf[BLOCK_SIZE * k + j]; - #endif - i += n; - } -#else - for (ma_uint32 i = 0; i < frameCount; i++) - out_buf[i] = 0.f; // Unique fake channel + float * out_buf = reinterpret_cast(pOutput); + ma_uint32 i = 0; +#if NUM_CHANNELS_IN > 0 + size_t ix = 0; #endif +#if NUM_CHANNELS_OUT > 0 + size_t iy = 0; +#endif + + while (i < frameCount) { + ma_uint32 n = std::min(frameCount - i, static_cast(BLOCK_SIZE)); + +#if NUM_CHANNELS_IN > 0 + for (ma_uint32 j = 0; j < n; j++) + for (size_t k = 0; k < NUM_CHANNELS_IN; k++, ix++) + x_buf[BLOCK_SIZE * k + j] = in_buf[ix]; +#endif + +#if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN + memset(zero, 0, BLOCK_SIZE * sizeof(float)); +#endif + + plugin_process(&instance, x, y, n); + +#if NUM_CHANNELS_OUT > 0 + for (ma_uint32 j = 0; j < n; j++) + for (size_t k = 0; k < NUM_CHANNELS_OUT; k++, iy++) + 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.f; +#endif + i += n; + } } #if (NUM_MIDI_INPUTS > 0) void (^midiNotifyBlock)(const MIDINotification *message) = ^(const MIDINotification *message) { - if (message->messageID != kMIDIMsgObjectAdded) - return; - const MIDIObjectAddRemoveNotification *n = reinterpret_cast(message); - MIDIEndpointRef endPoint = n->child; - MIDIPortConnectSource(midiPort, endPoint, NULL); + if (message->messageID != kMIDIMsgObjectAdded) + return; + const MIDIObjectAddRemoveNotification *n = reinterpret_cast(message); + MIDIEndpointRef endPoint = n->child; + MIDIPortConnectSource(midiPort, endPoint, NULL); }; void (^midiReceiveBlock)(const MIDIEventList *evtlist, void *srcConnRefCon) = ^(const MIDIEventList *evtlist, void *srcConnRefCon) { - const MIDIEventPacket *p = evtlist->packet; - for (UInt32 i = 0; i < evtlist->numPackets; i++) { - for (UInt32 j = 0; j < p->wordCount; j++) { - const UInt32 w = p->words[j]; - const uint8_t* t = (uint8_t*) &(w); - - if ((t[3] & 0xf0) != 32) - continue; // We only support MIDI 1.0 - if ((t[2] & 0xF0) == 0xF0) - continue; - mutex.lock(); - if (midiBuffer_i < MIDIBUFFERLEN - 3) { - midiBuffer[midiBuffer_i ] = t[2]; - midiBuffer[midiBuffer_i + 1] = t[1]; - midiBuffer[midiBuffer_i + 2] = t[0]; - midiBuffer_i += 3; - } - mutex.unlock(); - } - p = MIDIEventPacketNext(p); - } + const MIDIEventPacket *p = evtlist->packet; + for (UInt32 i = 0; i < evtlist->numPackets; i++) { + for (UInt32 j = 0; j < p->wordCount; j++) { + const UInt32 w = p->words[j]; + const uint8_t* t = (uint8_t*) &(w); + + if ((t[3] & 0xf0) != 32) + continue; // We only support MIDI 1.0 + if ((t[2] & 0xF0) == 0xF0) + continue; + mutex.lock(); + if (midiBuffer_i < MIDIBUFFERLEN - 3) { + midiBuffer[midiBuffer_i ] = t[2]; + midiBuffer[midiBuffer_i + 1] = t[1]; + midiBuffer[midiBuffer_i + 2] = t[0]; + midiBuffer_i += 3; + } + mutex.unlock(); + } + p = MIDIEventPacketNext(p); + } }; #endif extern "C" char audioStart() { - #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 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); # elif NUM_CHANNELS_OUT == 0 - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_capture); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_capture); # else - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_duplex); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_duplex); # endif #else - ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback); + ma_device_config deviceConfig = ma_device_config_init(ma_device_type_playback); #endif - deviceConfig.periodSizeInFrames = BLOCK_SIZE; - deviceConfig.periods = 1; - deviceConfig.performanceProfile = ma_performance_profile_low_latency; - deviceConfig.noPreSilencedOutputBuffer = 1; - deviceConfig.noClip = 0; - deviceConfig.noDisableDenormals = 0; - deviceConfig.noFixedSizedCallback = 1; - deviceConfig.dataCallback = data_callback; - deviceConfig.capture.pDeviceID = NULL; - deviceConfig.capture.format = ma_format_f32; - deviceConfig.capture.channels = NUM_CHANNELS_IN; - deviceConfig.capture.shareMode = ma_share_mode_shared; - deviceConfig.playback.pDeviceID = NULL; - deviceConfig.playback.format = ma_format_f32; + deviceConfig.periodSizeInFrames = BLOCK_SIZE; + deviceConfig.periods = 1; + deviceConfig.performanceProfile = ma_performance_profile_low_latency; + deviceConfig.noPreSilencedOutputBuffer = 1; + deviceConfig.noClip = 0; + deviceConfig.noDisableDenormals = 0; + deviceConfig.noFixedSizedCallback = 1; + deviceConfig.dataCallback = data_callback; + deviceConfig.capture.pDeviceID = NULL; + deviceConfig.capture.format = ma_format_f32; + deviceConfig.capture.channels = NUM_CHANNELS_IN; + deviceConfig.capture.shareMode = ma_share_mode_shared; + deviceConfig.playback.pDeviceID = NULL; + deviceConfig.playback.format = ma_format_f32; #if NUM_CHANNELS_IN + NUM_CHANNELS_OUT > 0 - deviceConfig.playback.channels = NUM_CHANNELS_OUT; + deviceConfig.playback.channels = NUM_CHANNELS_OUT; #else - deviceConfig.playback.channels = 1; // Fake & muted + deviceConfig.playback.channels = 1; // Fake & muted #endif - deviceConfig.playback.shareMode = ma_share_mode_shared; + deviceConfig.playback.shareMode = ma_share_mode_shared; - if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) - return false; + if (ma_device_init(NULL, &deviceConfig, &device) != MA_SUCCESS) + return false; #if (NUM_MIDI_INPUTS > 0) - if (midiClientName == NULL) { - midiClientName = CFSTR("template"); - if (midiClientName == NULL) - return false; // Check unint - } - if (midiClient == (MIDIClientRef)NULL) { - if (MIDIClientCreateWithBlock(midiClientName, &midiClient, midiNotifyBlock) != 0) - return false; - } - if (midiInputName == NULL) { - midiInputName = CFSTR("Input"); - if (midiInputName == NULL) - return false; - } - if (midiPort == (MIDIPortRef)NULL) { - if (MIDIInputPortCreateWithProtocol(midiClient, midiInputName, kMIDIProtocol_1_0, &midiPort, midiReceiveBlock) != 0) - return false; + if (midiClientName == NULL) { + midiClientName = CFSTR("template"); + if (midiClientName == NULL) + return false; // Check unint + } + if (midiClient == (MIDIClientRef)NULL) { + if (MIDIClientCreateWithBlock(midiClientName, &midiClient, midiNotifyBlock) != 0) + return false; + } + if (midiInputName == NULL) { + midiInputName = CFSTR("Input"); + if (midiInputName == NULL) + return false; + } + if (midiPort == (MIDIPortRef)NULL) { + if (MIDIInputPortCreateWithProtocol(midiClient, midiInputName, kMIDIProtocol_1_0, &midiPort, midiReceiveBlock) != 0) + return false; - ItemCount n = MIDIGetNumberOfSources(); - for (ItemCount i = 0; i < n; i++) { - MIDIEndpointRef endPoint = MIDIGetSource(i); - MIDIPortConnectSource(midiPort, endPoint, NULL); - } - } + ItemCount n = MIDIGetNumberOfSources(); + for (ItemCount i = 0; i < n; i++) { + MIDIEndpointRef endPoint = MIDIGetSource(i); + MIDIPortConnectSource(midiPort, endPoint, NULL); + } + } #endif - - plugin_init(&instance); - + + plugin_init(&instance); + #if PARAMETERS_N > 0 - for (size_t i = 0; i < PARAMETERS_N; i++) { - if (!param_data[i].out) - plugin_set_parameter(&instance, i, param_data[i].def); - param_values_prev[i] = param_values[i] = param_data[i].def; - } + for (size_t i = 0; i < PARAMETERS_N; i++) { + if (!param_data[i].out) + plugin_set_parameter(&instance, i, param_data[i].def); + param_values_prev[i] = param_values[i] = param_data[i].def; + } #endif - - plugin_set_sample_rate(&instance, (float)device.sampleRate); + + plugin_set_sample_rate(&instance, (float)device.sampleRate); - size_t req = plugin_mem_req(&instance); - if (req != 0) { - mem = malloc(req); - if (mem == NULL) { - plugin_fini(&instance); - ma_device_uninit(&device); - return false; - } - plugin_mem_set(&instance, mem); - } else - mem = NULL; + size_t req = plugin_mem_req(&instance); + if (req != 0) { + mem = malloc(req); + if (mem == NULL) { + plugin_fini(&instance); + ma_device_uninit(&device); + return false; + } + plugin_mem_set(&instance, mem); + } else + mem = NULL; - plugin_reset(&instance); - + plugin_reset(&instance); + #if NUM_ALL_CHANNELS_IN > 0 # if AUDIO_BUS_IN >= 0 - size_t ix = 0; - size_t ixb = 0; - for (size_t j = 0; j < NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT; j++) { - if (audio_bus_data[j].out) - continue; - if (audio_bus_data[j].index == AUDIO_BUS_IN) - for (char k = 0; k < audio_bus_data[j].channels; k++, ix++, ixb++) - x[ix] = x_buf + BLOCK_SIZE * ixb; + size_t ix = 0; + size_t ixb = 0; + for (size_t j = 0; j < NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT; j++) { + if (audio_bus_data[j].out) + continue; + if (audio_bus_data[j].index == AUDIO_BUS_IN) + for (char k = 0; k < audio_bus_data[j].channels; k++, ix++, ixb++) + x[ix] = x_buf + BLOCK_SIZE * ixb; # if NUM_NON_OPT_CHANNELS_IN > NUM_CHANNELS_IN - else if (!audio_bus_data[j].optional) - for (char k = 0; k < audio_bus_data[j].channels; k++, ix++) - x[ix] = zero; + else if (!audio_bus_data[j].optional) + for (char k = 0; k < audio_bus_data[j].channels; k++, ix++) + x[ix] = zero; # endif - else - for (char k = 0; k < audio_bus_data[j].channels; k++, ix++) - x[ix] = NULL; - } + else + for (char k = 0; k < audio_bus_data[j].channels; k++, ix++) + x[ix] = NULL; + } # else - for (size_t i = 0; i < NUM_ALL_CHANNELS_IN; i++) - x[i] = NULL; + for (size_t i = 0; i < NUM_ALL_CHANNELS_IN; i++) + x[i] = NULL; # endif #else - x = NULL; + x = NULL; #endif - + #if NUM_ALL_CHANNELS_OUT > 0 # if AUDIO_BUS_OUT >= 0 - size_t iy = 0; - size_t iyb = 0; - for (size_t j = 0; j < NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT; j++) { - if (!audio_bus_data[j].out) - continue; - if (audio_bus_data[j].index == AUDIO_BUS_OUT) - for (char k = 0; k < audio_bus_data[j].channels; k++, iy++, iyb++) - y[iy] = y_buf + BLOCK_SIZE * iyb; + size_t iy = 0; + size_t iyb = 0; + for (size_t j = 0; j < NUM_AUDIO_BUSES_IN + NUM_AUDIO_BUSES_OUT; j++) { + if (!audio_bus_data[j].out) + continue; + if (audio_bus_data[j].index == AUDIO_BUS_OUT) + for (char k = 0; k < audio_bus_data[j].channels; k++, iy++, iyb++) + y[iy] = y_buf + BLOCK_SIZE * iyb; # if NUM_NON_OPT_CHANNELS_OUT > NUM_CHANNELS_OUT - else if (!audio_bus_data[j].optional) - for (char k = 0; k < audio_bus_data[j].channels; k++, iy++) - y[iy] = zero; + else if (!audio_bus_data[j].optional) + for (char k = 0; k < audio_bus_data[j].channels; k++, iy++) + y[iy] = zero; # endif - else - for (char k = 0; k < audio_bus_data[j].channels; k++, iy++) - y[iy] = NULL; - } + else + for (char k = 0; k < audio_bus_data[j].channels; k++, iy++) + y[iy] = NULL; + } # else - for (size_t i = 0; i < NUM_ALL_CHANNELS_OUT; i++) - y[i] = NULL; + for (size_t i = 0; i < NUM_ALL_CHANNELS_OUT; i++) + y[i] = NULL; # endif #else - y = NULL; + y = NULL; #endif - - if (ma_device_start(&device) != MA_SUCCESS) { - if (mem != NULL) - free(mem); - ma_device_uninit(&device); - return false; - } - return true; + + if (ma_device_start(&device) != MA_SUCCESS) { + if (mem != NULL) + free(mem); + ma_device_uninit(&device); + return false; + } + return true; } extern "C" void audioStop() { - ma_device_stop(&device); - ma_device_uninit(&device); - if (mem != NULL) - free(mem); - plugin_fini(&instance); - // No need to close MIDI connections (e.g. via MIDIClientDispose), the system terminates them when the app terminates. + ma_device_stop(&device); + ma_device_uninit(&device); + if (mem != NULL) + free(mem); + plugin_fini(&instance); + // No need to close MIDI connections (e.g. via MIDIClientDispose), the system terminates them when the app terminates. } extern "C" float getParameter(int i) { #if PARAMETERS_N > 0 - mutex.lock(); - float v = param_values[i]; - mutex.unlock(); - return v; + mutex.lock(); + float v = param_values[i]; + mutex.unlock(); + return v; #else - return 0.f; + (void)i; + return 0.f; #endif } extern "C" void setParameter(int i, float v) { - if (param_data[i].flags & (PARAM_BYPASS | PARAM_TOGGLED)) - v = v > 0.5f ? 1.f : 0.f; - else if (param_data[i].flags & PARAM_INTEGER) - v = (int32_t)(v + 0.5f); - v = std::min(std::max(v, param_data[i].min), param_data[i].max); + if (param_data[i].flags & (PARAM_BYPASS | PARAM_TOGGLED)) + v = v > 0.5f ? 1.f : 0.f; + else if (param_data[i].flags & PARAM_INTEGER) + v = (int32_t)(v + 0.5f); + v = std::min(std::max(v, param_data[i].min), param_data[i].max); #if PARAMETERS_N > 0 - mutex.lock(); - param_values[i] = v; - mutex.unlock(); + mutex.lock(); + param_values[i] = v; + mutex.unlock(); #endif } diff --git a/templates/ios/src/platform.h b/templates/ios/src/platform.h deleted file mode 100644 index 962b66f..0000000 --- a/templates/ios/src/platform.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef PLATFORM_H -#define PLATFORM_H - -#define NDEBUG - -#endif diff --git a/templates/ios/tibia-index.js b/templates/ios/tibia-index.js index 6e6b85f..c7085d6 100644 --- a/templates/ios/tibia-index.js +++ b/templates/ios/tibia-index.js @@ -3,9 +3,8 @@ var sep = path.sep; module.exports = function (data, api) { 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}app-Bridging-Header.h`, `src${sep}app-Bridging-Header.h`); - api.copyFile(`src${sep}platform.h`, `src${sep}platform.h`); - api.generateFileFromTemplateFile(`src${sep}app.swift`, `src${sep}app.swift`, data); - api.generateFileFromTemplateFile(`src${sep}index.html`, `src${sep}index.html`, data); + api.copyFile(`src${sep}app.swift`, `src${sep}app.swift`, data); }; diff --git a/test/ios-make.json b/test/ios-make.json index e458bb6..9b267b2 100644 --- a/test/ios-make.json +++ b/test/ios-make.json @@ -1,11 +1,8 @@ { "ios_make": { - "header_search_paths": [], - "3rdpartyfiles": [ - "../../../miniaudio/miniaudio.h" - ], - "projectName": "tibia_test", - "targetName": "tibia_test", + "headerSearchPaths": [], + "sourcesExtra": [], + "productBundleIdentifier": "com.example.tibia_test", "deploymentTarget": 16.6 } } diff --git a/test/ios.json b/test/ios.json deleted file mode 100644 index 4eb7c3f..0000000 --- a/test/ios.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} \ No newline at end of file diff --git a/test/run.sh b/test/run.sh index e8ac9f0..389db8f 100755 --- a/test/run.sh +++ b/test/run.sh @@ -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/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/ios.json,$dir/ios-make.json $dir/../templates/ios-make $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-make.json $dir/../templates/ios-make $dir/../out/ios 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