This is the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Getting Started

Let’s start your mimium experiences

Prerequisites

Currently, mimium can be used on the following environments.

  • macOS (x86)
  • Linux(tested on Ubuntu, uses ALSA as backend)
  • Windows 10

Getting started with an extension for Visual Studio Code

The easiest way to get started is to use Visual Studio Code, a free text editor/IDE.

  1. download and install Visual Studio Code from the official website.
  2. Start Visual Studio Code, and open the Extensions menu (Cmd+Shift+X).
  3. search for “mimium” in the search field and install it.
  4. Create a file with the name of `hello.mmm’, copy the following code snippet, save it, and open it again in Visual Studio Code.
  5. A pop-up window will appear asking you to install the latest version of the mimium binary.
  6. Cmd+Shift+P to open the command palette, search for “mimium”, and execute the command “Run currently opening file” to run the file currently open in the editor from the terminal.
  7. If you want to stop the sound, press Ctrl+C in the terminal.
// hello.mmm
fn dsp(){
  output = sin(now*440*2*3.141595/48000)
  return (output,output)
}

Other ways to install

You can download latest binaries from GitHub Release. Copy bin/mimium to appropariate path (for example, /usr/loca/bin on macOS/Linux).

On macOS/Linux, you can easily install mimium by using Homebrew/Linuxbrew1.

brew install mimium-org/mimium/mimium

for more detailed information such as building from source, check Installation page.

Run the command

You can run mimium by running mimium command. If the binary is correctly installed, you can see the help menu with the following command.

mimium --help

Make text file with the name of hello.mmm on current working directory and paste the code snippet above.

Then, type the following command to run the file. (Take care the volume of speakers.) You will hear the sine wave sound of 440Hz.

mimium hello.mmm

Conguraturations!

You can read further explanation such as a grammer of the language and available functions on Making Sound page.


  1. Currently, we can not provide a binary package for macOS 11.0 thus it tries to build from the source. Installing Xcode and some additional software are required. ↩︎

1 - Examples

The entry point for the beginners of mimium - step by step example.
  1. dsp
  2. “self” example
  3. a simple effect
  4. composition
  5. sol-fa
  6. rhythm pattern

Example: sol-fa

In the example below, the system’s audio driver sample rate is 48000 Hz, and it will play sol-fa sounds every second.

notes = [440,495,260.7,293.3,330,347.7,391.1]
index = 0
fn updateIndex(){
  index = (index+1)%7
  updateIndex()@(now+48000)
}
updateIndex()@48000
fn dsp(){
 vol = 0.2
 octave = 1
 sec = now/48000
 freq = notes[index]
 out = vol * sin(octave*freq*3.14*2*sec)
 return (0,out)
}

Point 1: Arrays.

notes = [440,495,260.7,293.3,330,347.7,391.1] // 1st line

In mimium, you can define an array. Arrays are defined using []. The beginning of the index is 0. In this example, the first line of the array that creates the sol-fa sounds note contains the frequencies of the A-B-C-D-E-F-G notes, which are used in subsequent processing.

  • A: 440Hz
  • B: 495Hz
  • C: 260.7Hz
  • D: 293.3Hz
  • E: 330Hz
  • F: 347.7Hz
  • G: 391.1Hz

The way to use arrays is to use array_name[index], as in line 12. freq = notes[index] // line 12.

Point 2: Temporal Recursion

// Lines 3~7
fn updateIndex(){
  index = (index+1)%7
  updateIndex()@(now+48000)
}
updateIndex()@48000

V0.3.0 does not adopt the for-loop statement that most languages have. However, you can describe repetitive executions of the function by using a design pattern called temporal recursion as shown in lines 3~6. In the sol-fa example, after executing updateIndex() at 48000 samples in line 7, the now and @ keywords are used together in the function to execute updateIndex() at 48000 samples from the current time (line 5).

Point 3: Using the now and @ keywords together

updateIndex()@(now+48000) // line 5

In mimium, the current number of samples can be retrieved using now. Users should note that in the v0.3.0 current specification, the now keyword does not represent real-time. The unit is sample1.

Also, mimium has a @ keyword, which means “execute the function before @ when the number of samples is the number of values resulting from the calculation of the expression after @.

The @ time indicates the absolute time since the audio driver was started, so if you write updateIndex()@48000 as in line 7, it will always execute updateIndex() once 48000 samples after it was started. In the fifth line of the example, by connecting now and 48000 with the + keyword, we can determine the sample point in time from the current time, and by using @, we can execute the function at that sample point.

Point 4: Octave

// Lines 8~15
fn dsp(){
 vol = 0.2
 octave = 1
 sec = now/48000
 freq = notes[index]
 out = vol  *sin(octave*freq*3.14*2*sec)
 return (0,out)
}

In the musical scale, there is a relationship between doubling the frequency (Hz) and going up an octave, and conversely, halving the frequency and going down an octave. In lines 8 to 15 of the example, the value is fixed at octave = 1, so it plays a sol-fa sounds from 260.7Hz to 495Hz, but if you change this value to 2, for example, you can express a scale that goes up an octave.


  1. mimium currently does not provide a way to get a samplerate of the audio driver. In the future, this will be realized by introducing environment-variables(runtime-defined variables). ↩︎

2 - Making Sound

Here you will learn how to make the basic sound using the mimium.

Documentation is under preparation! We are seeking for people who support documentations and translations.

Making 440Hz Sine wave sound

  1. Prepare a MMM file(e.g. sin.mmm). If you haven’t installed mimium at this point, see Installation.
  2. Write the following code and saving the file.
fn dsp(time){
    return sin(now*440*3.14*2/48000)
}

Otherwise you can write one-liner code snippets.

dsp = |t|{ sin(now*440*3.14*2/48000) }
  1. Using your command line tool (e.g. bash), run the previous code.
$ mimium sin.mmm

3 - Installation

Install mimium to your computer

Documentation is under preparation! We are seeking for people who support documentations and translations.

Install through homebrew

For easier installation, using Homebrew, a package manager tool for macOS and Linux is recommended.

If you have not installed homebrew, open terminal app and copy & paste next line and hit Enter key.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

If you got homebrew, you can install mimium by typing

brew install mimium-org/mimium/mimium

That’s it! You can check if you have successfully installed or not by

mimium --version # will return mimium version:x.x.x

Install manually

You can download built binary from GitHub Release Page.

mimium-vx.x.x-Darwin.zip is for macOS, mimium-vx.x.x-Linux.zip is for Linux and mimium-vx.x.x-Windows.zip is for Windows.

After finished downloading and extracting zip files, copy mimium inside bin folder into /usr/local/bin, all files inside lib into /usr/local/lib. On GNU/Linux, note that the directory /usr/local/lib is not in library path by default, so don’t forget to add this directory to /etc/ld.so.conf.d/ and run ldconfig as root.

Build from source manually

mimium compiler & runtime are written in C++ thus you need C++ compiler. Xcode clang on macOS(you can install by just typing xcode-select --install) and GCC >= 9 is recommended on Linux.

You also need several libraries and build tools below.

on macOS, git and cmake are installed if you got xcode clang.

Also the codes depends on RtAudio(a cross-platform audio driver library) library but it will be downloaded & built automatically by cmake at a configure step.

You can of course install these dependencies via brew, or apt-get.

Get a source code from GitHub repository

git clone https://github.com/mimium-org/mimium.git
cd mimium
# 'master' branch is a stable version. You can get the development version from 'dev' branch. 
git checkout master 

Configure CMake

mkdir build && cd build
cmake .. 

At this step, CMake will download and build RtAudio Library. You can pass generic options for CMake configuration option, for example,

  • -DCMAKE_INSTALL_PREFIX=/your/directory specifies installation path.
  • -DCMAKE_BUILD_TYPE=Debug specifies build optimization level. You can choose from ‘Debug’, ‘Release’, ‘MinSizeRel’ , ‘RelWithDebinfo’
  • -DCMAKE_CXX_COMPILER=/path/to/compiler specifies C++ compiler.
  • -DBUILD_SHARED_LIBS=ON Build libraries as dynamic-link library.(Not well tested on Linux and Windows)。
  • -DBUILD_TEST=ON Include tests to build targets.
  • -DENABLE_COVERAGE=ON Enable compiler option to calculate code-cvoerage using GCov.

Build

cmake --build build -j

-j option controls maximum number of parallel CPU threads usage(e.g. -j8 means up to 8 threads). -j with no number means possible maximum number on your platform.

Install

cmake --build build target=install

Uninstall

#(on build folder)
cmake --build build --target uninstall

This uninstall target uses information on build/install_manifest.txt generated by CMake at installation steps. If you fail to remove files, check this file and try build , installation and uninstall steps sequentialy again.

Syntax Highlight for Visual Studio Code

Currently, we have a syntax highlight for Visual Studio Code, a cross platform text editor/development environment.

You can get by searching mimium-language on an extension panel on VS Code or you can get from the link below.

https://marketplace.visualstudio.com/items?itemName=mimium-org.mimium-language