Skip to content

Commit

Permalink
push to github
Browse files Browse the repository at this point in the history
Signed-off-by: Martmists <martmists@gmail.com>
  • Loading branch information
Martmists-GH committed Jun 21, 2022
1 parent 44880bf commit 358111e
Show file tree
Hide file tree
Showing 138 changed files with 1,377 additions and 4,034 deletions.
18 changes: 17 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ ij_smart_tabs = false
ij_visual_guides = none
ij_wrap_on_typing = false

[{*.gradle.kts,*.kt,*.kts,*.main.kts,*.space.kts}]
[*.properties]
ij_properties_align_group_field_declarations = false
ij_properties_keep_blank_lines = false
ij_properties_key_value_delimiter = equals
ij_properties_spaces_around_key_value_delimiter = false

[.editorconfig]
ij_editorconfig_align_group_field_declarations = false
ij_editorconfig_space_after_colon = false
ij_editorconfig_space_after_comma = true
ij_editorconfig_space_before_colon = false
ij_editorconfig_space_before_comma = false
ij_editorconfig_spaces_around_assignment_operators = true

[{*.kt,*.kts}]
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
Expand Down Expand Up @@ -61,6 +75,7 @@ ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = false
ij_kotlin_line_comment_add_space_on_reformat = false
ij_kotlin_line_comment_at_first_column = true
ij_kotlin_method_annotation_wrap = split_into_lines
ij_kotlin_method_call_chain_wrap = normal
Expand Down Expand Up @@ -93,6 +108,7 @@ ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_use_custom_formatting_for_modifiers = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,5 @@ dmypy.json
cython_debug/

### Custom
python.def
.python-version
/kaudio/
/src/nativeInterop/cinterop/numpy.def
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# KAudio Python Wrapper

A reimplementation of my kaudio library for Python.
A reimplementation of my kaudio library for Python 3.10+

# Application

An application is bundled by default:

```
$ pip install .
$ cd python_src
$ python3 -m kaudio_app
$ pip install Qt.py # required due to an issue in NodeGraphQt
$ pip install --user .[app] # on zsh: pip install --user .\[app\]
$ python3 -m kaudio.app
```

# Usage
Expand Down
52 changes: 27 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import com.martmists.kpy.plugin.PythonVersion

plugins {
kotlin("multiplatform") version "1.6.0"
kotlin("multiplatform") version "1.7.0"
id("com.martmists.kpy.kpy-plugin") version "0.3.5-1.7.0"
}

group = "com.martmists"
version = "1.0-SNAPSHOT"

repositories {
mavenCentral()
}
version = "0.0.1"

kotlin {
val hostOs = System.getProperty("os.name")
Expand All @@ -19,11 +17,24 @@ kotlin {
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}

sourceSets {
val main by creating {

}

val nativeMain by getting {

}
}

nativeTarget.apply {
val main by compilations.getting
val python by main.cinterops.creating { }
val bs2b by main.cinterops.creating { }
val freeverb by main.cinterops.creating { }
val main by compilations.getting {
cinterops {
val bs2b by creating { }
val freeverb by creating { }
val utilities by creating { }
}
}

binaries {
staticLib {
Expand All @@ -33,20 +44,11 @@ kotlin {
}
}

val cinteropBs2bNative by tasks.getting {
dependsOn("libraries:bs2b:build")
}

val cinteropFreeverbNative by tasks.getting {
dependsOn("libraries:freeverb:build")
}

val compileKotlinNative by tasks.getting {
dependsOn("cinteropBs2bNative")
dependsOn("cinteropFreeverbNative")
dependsOn("cinteropPythonNative")
allprojects {
buildDir = file("${rootProject.rootDir.absolutePath}/build/${project.name}")
}

val install by tasks.register<Exec>("install") {
commandLine = listOf("pip3", "install", "-U", ".")
kpy {
pyVersion = PythonVersion.Py310
generateStubs = true
}
6 changes: 4 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
kotlin.mpp.stability.nowarn=true
kotlin.native.binary.sourceInfoType=libbacktrace
kotlin.native.cacheKind.linuxX64=none
org.gradle.jvmargs=-Xmx1G -XX:MaxMetaspaceSize=512m
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.5-20220429115913+0000-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 0 additions & 3 deletions libraries/bs2b/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ plugins {

library {
linkage.set(listOf(Linkage.STATIC))
source.from("src")
publicHeaders.from("src")
privateHeaders.from("src")
}

val build by tasks.getting {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions libraries/freeverb/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ plugins {

library {
linkage.set(listOf(Linkage.STATIC))
source.from("src")
publicHeaders.from("src")
privateHeaders.from("src")
}

val build by tasks.getting {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions libraries/utilities/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
plugins {
`cpp-library`
`cpp-unit-test`
}

library {
linkage.set(listOf(Linkage.STATIC))
}

unitTest {
targetMachines.set(listOf(machines.linux.x86_64))
}

val build by tasks.getting {
dependsOn("assembleRelease")
dependsOn("assembleDebug")
}
42 changes: 42 additions & 0 deletions libraries/utilities/src/main/cpp/shiftarray.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "shiftarray.h"
#include <cstring>
#include <cstdlib>
#include <cstdio>

inline int array_index(shift_array_t* array, int index) {
int res = ((int)array->offset + index);
if (res < 0) {
res += array->size;
}
return res % array->size;
}

shift_array_t* array_alloc(unsigned int size) {
shift_array_t* array = (shift_array_t*)malloc(sizeof(shift_array_t));
array->size = size;
array->offset = 0;
array->data = (float*)malloc(size * sizeof(float));
memset(array->data, 0, size * sizeof(float));
return array;
}

void array_free(shift_array_t* array) {
free(array->data);
free(array);
}

float array_get(shift_array_t* array, int index) {
return array->data[array_index(array, index)];
}

void array_set(shift_array_t* array, int index, float value) {
array->data[array_index(array, index)] = value;
}

void array_shift(shift_array_t* array, int num) {
array->offset = array_index(array, num);
}

void array_clear(shift_array_t* array) {
memset(array->data, 0, array->size * sizeof(float));
}
22 changes: 22 additions & 0 deletions libraries/utilities/src/main/headers/shiftarray.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
unsigned int size;
int offset;
float* data;
} shift_array_t;

shift_array_t* array_alloc(unsigned int size);
void array_free(shift_array_t* array);
float array_get(shift_array_t* array, int index);
void array_set(shift_array_t* array, int index, float value);
void array_shift(shift_array_t* array, int num);
void array_clear(shift_array_t* array);

#ifdef __cplusplus
}
#endif
11 changes: 11 additions & 0 deletions libraries/utilities/src/main/headers/utilities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "shiftarray.h"

#ifdef __cplusplus
}
#endif
89 changes: 0 additions & 89 deletions python_src/.editorconfig

This file was deleted.

Loading

0 comments on commit 358111e

Please sign in to comment.