Use MathGL to generate piano sound using OpenAL in Kolin

Submitted by Dickens A S on Sun, 08/01/2021 - 14:05

This article demonstrates how to use MathGL to generate a sine wave and modify it using a cosine envelope and transfer that data to the OpenAL

MathGL is a versatile matrix and array manipulation library, It can be used for stats, numerical methods, simulation, graphics, games etc., 

This article peculiarly uses it for creating an audio. Audio is simply a sequence by bytes sent an amplifier and a speaker. 

Therefore it can be generated using any numerical methodology and set in an array of bytes.

Below code explains how it is done.

Full Kotlin code

Combine / Call Fortran DLL inside Kotlin Native using Gradle KTS

Submitted by Dickens A S on Thu, 07/22/2021 - 10:54

Call Fortran from Kotlin Native

This article demonstrates how to change the toolchain name using Gradle KTS and invoke gfortran compiler instead of g++ compiler and produce a DLL and reuse a Fortran subroutine or function inside a Kotlin Native code

There is a sub project named libfort1 which has Gradle KTS file, it has been improved to trigger a different exe command line using Gradle Action APIs, which allows the developer to modify the executable as well as parameters sent to the executable

Launch Visual Studio Code From MSYS2

Submitted by Dickens A S on Wed, 07/21/2021 - 05:35

This article demonstrates How to launch vscode.exe with MSYS2

Download Visual Studio Code

download the .zip version of the VS Code from the below URL

https://code.visualstudio.com/download

Unzip the .zip into C:\msys64\opt\vscode

Launch VS Code

open 64 bit MINGW by running c:\msys64\mingw64.exe

check version of vs code by running 

$ /opt/vscode/bin/code --version
1.58.2
c3f126316369cd610563c75b1b1725e0679adfb3
x64

launch vs code be running 

Installing R inside MSYS2 using Miniconda in Windows

Submitted by Dickens A S on Tue, 07/20/2021 - 06:19

This article demonstrates how install R using Miniconda inside MSYS2 MINGW64 shell

Download and install Miniconda

Install miniconda iniside c:\msys64\opt\miniconda without adding to PATH

Set PATH environment variable permanently in MSYS2 .bashrc

Open c:\msys64\home\<username>\.bashrc and add scripts folder to the PATH

Example .bashrc

Kotlin JVM JNI C++ Inheritance and Callback using SWIG

Submitted by Dickens A S on Tue, 07/20/2021 - 03:59

This Article demonstrates how to Inherit class from C++ class and how to make C++ calls back the Kolin function using overriding

In case there is Java or Kotlin inheritance is used how a JNI function get a handle for that.

System.loadLibrary is used to load the JNI library in JVM.

Below code explains how the inherited function is invoked and a callback which is written in Java or kotlin is invoked from a C++ code.

The Gradle SWIG Task of cpplib

Kotlin JVM JNI using SWIG Arrays and Pointers

Submitted by Dickens A S on Mon, 07/19/2021 - 09:28

This Article demonstrates how to pass pointers and arrays in and out using pure C code and JNI and force pure C code in Gradle

The Gradle SWIG Task of cpplib

val swigTask: Exec by tasks.creating(Exec::class) {
	commandLine (
		"swig",
		"-java",
		"-cppext",
		"c",
		"-addextern",
		"-module",
		"${project.name}",
		"src\\main\\swig\\${project.name}.i"
	)
}

The Gradle C Compiler Arguments (-lc -x c -std=gnu99) forces the g++ to use gcc compiler as pure C compiler

Embed PERL in Kotlin or call PERL from Kotlin in Windows using MSYS2

Submitted by Dickens A S on Thu, 07/15/2021 - 07:01

This article demonstrates how to call PERL from Kotlin using C APIs

PERL is very old platform. But it is still being used in libraries like GIT and firewall and admin software.

If the developer knows how to invoke a PERL function then from a GUI based software the developer can invoke the function.

Below code explains how to do it.

Kotlin Code

Connect SQLite from gnu COBOL in Windows

Submitted by Dickens A S on Mon, 07/12/2021 - 08:37

This article demonstrates how connect SQLite3 from COBOL using MSYS2 in WIndows

get sqlite3.c from the sqlite amalagation zip can be found in sqlite.org download.html

and put that file in the same place where your cobol code is compiled

"test.db" is pre created with DBeaver plugin in eclipse

Install sqlite3 in MSYS2 using

$ pacman -S libsqlite libsqlite-devel mingw-w64-x86_64-sqlite3

Compile the C code