vitreo12 / omni

DSL for low-level audio programming.
https://vitreo12.github.io/omni/
MIT License
188 stars 6 forks source link

Example in README does not compile #154

Closed jgarte closed 3 years ago

jgarte commented 3 years ago

Hi Francesco,

I tried compiling the example in the README but I get the following error:

$ .nimble/bin/omni sine.omni
stack trace: (most recent call last)
omni_io.nim(651, 26)     omni_ins_inner
/home/jgart/.nimble/pkgs/omni_lang-0.4.0/omni_lang/core/lang/omni_io.nim(755, 12) template/generic instantiation of `omni_ins_inner` from here
/home/jgart/sine.omni(1, 7) Error: ins: Invalid syntax: '1'

This is what my sine.omni file contains:

ins:  1
outs: 1

init:
    phase = 0.0

sample:
    incr  = in1 / samplerate
    out1  = sin(phase * TWOPI)
    phase = (phase + incr) % 1.0

This is the version of nim that I am using:

$ nim -v
Nim Compiler Version 1.4.6 [Linux: amd64]
Compiled at 2021-04-15
Copyright (c) 2006-2020 by Andreas Rumpf

Any ideas of how I can fix this? Should the README example be updated to reflect the current omni API or does the error lie elsewhere?

vitreo12 commented 3 years ago

Hi!

What version of Omni are you using?

vitreo12 commented 3 years ago

Ah, found the mistake... It's a regression from a rework I did a couple of releases ago. Will fix it ASAP! Thanks :)

vitreo12 commented 3 years ago

I have rebased the 0.4.0 release to the new commit. If you nimble uninstall omni and nimble install omni again you should get it!

It definitely was a silly mistake on my end :)

jgarte commented 3 years ago

Hi!

What version of Omni are you using?

 .nimble/bin/omni -v
Omni - version 0.4.0
(c) 2020-2021 Francesco Cameli

If you nimble uninstall omni and nimble install omni again you should get it!

I uninstalled and installed omni but now I get the following error:

$ .nimble/bin/omni Sine.omni

sh: nm: command not found
ERROR: Undefined 'perform' or 'sample' blocks.

Is there something wrong with my input file or is it maybe something else?

$ cat Sine.omni
ins:  1
outs: 1

init:
    phase = 0.0

sample:
    incr  = in1 / samplerate
    out1  = sin(phase * TWOPI)
    phase = (phase + incr) % 1.0
vitreo12 commented 3 years ago

What Linux distribution are you using? It appears you don't have nm installed (or not in your $PATH), which is a standard gcc utility.

jgarte commented 3 years ago

I'm on NixOS on this machine that is having the issues.

I think I have to do some homework on how to set up a proper environment on NixOS for doing work with nim/omni.

Here are some issues regarding compiling packages with nim on NixOS in case you are interested:

https://discourse.nixos.org/t/unresolved-symbols-using-nim/11320/1 https://discourse.nixos.org/t/nix-flake-of-nim-lang-packages/5267 https://github.com/adamlwgriffiths/nix-nim

I tried on a 32 bit cpu that is running void and omni compiled the Sine.omni file just fine.

I was able to inspect the libSine.so with nm.

vitreo12 commented 3 years ago

I see! I have never used NixOS, but I am pretty sure the only problem in this case is to install nm. Glad it worked on a 32bit CPU, which I actually never tested Omni on :)

jgarte commented 3 years ago

I tried installing nm by installing the binutils package which contains it .

$ whereis nm

nm: /nix/store/3xkamqvr4901xcwilzan3ijq29irpd8d-user-environment/bin/nm
$ which nm

/home/jgart/.nix-profile/bin/nm

This is the error I get now when I try to compile OmniSaw.omni:

$ .nimble/bin/omni ~/.nimble/pkgs/omni-0.4.0/examples/OmniSaw.omni -o:./

/home/jgart/.nimble/pkgs/omni-0.4.0/examples/OmniSaw.omni(1, 1) template/generic instantiation of `params` from here
/home/jgart/.nimble/pkgs/omni_lang-0.4.0/omni_lang/core/lang/omni_io.nim(1872, 12) template/generic instantiation of `omni_params_inner` from here
/home/jgart/.nimble/pkgs/omni_lang-0.4.0/omni_lang/core/lang/omni_io.nim(1830, 41) Error: expression has no address

I get the same error for Sine.omni:

$ .nimble/bin/omni Sine.omni

/home/jgart/Sine.omni(1, 1) template/generic instantiation of `ins` from here
/home/jgart/.nimble/pkgs/omni_lang-0.4.0/omni_lang/core/lang/omni_io.nim(761, 12) template/generic instantiation of `omni_ins_inner` from here
/home/jgart/.nimble/pkgs/omni_lang-0.4.0/omni_lang/core/lang/omni_io.nim(719, 41) Error: expression has no address

I also have gcc installed:

$ whereis gcc
gcc: /nix/store/3xkamqvr4901xcwilzan3ijq29irpd8d-user-environment/bin/gcc
vitreo12 commented 3 years ago

Both examples compile for me...

Do they work on your other machine? This might be a problem with NixOS.

jgarte commented 3 years ago

Both examples compile for me...

Do they work on your other machine? This might be a problem with NixOS.

Yes, both examples compile fine on the machine running void linux. I think this is a NixOS problem also.

I'll have to investigate what is the correct way to deal with this on NixOS. I'll ask in their discourse.

The author of flake-nimble wrote a blog post about nim that mentions in passing nim and NixOS issues:

I have made some effort at managing Nimble using Nix, but it's always been too fragile to work consistenly.

https://gemini.spam.works/~/emery/why-nim.gmi

vitreo12 commented 3 years ago

I see! Let me know about your findings :)