2

I work on computational music. I have found the ps13 pitch spelling algorithm implemented in Lisp in 2003, precisely "Digitool MCL 4.3". I would like to run this code, preferably on a Linux x86 machine, to compare its results with other similar codes.

I am new to Lisp, but so far my research led me to think that Digitool MCL is no longer available. I thought of two ways which may help me:

  • a virtual environment (Docker or else) which would emulate a machine from 2003…
  • a code translation tool which would transform the 2003 source code into something executable today

I have not succeeded in finding one of these two options, nor running it directly with sbcl (but, as a newbie, I may have missed a small modification to make it run easily).

May someone help me?

rfs
  • 81
  • 5
  • 1
    Common Lisp is a standardized language and MCL implements this Common Lisp. If there are no specifics used, then this code would probably run in other implementations. If the code has MCL & Mac specific features used, then it needs some porting. You need to look at the code to see if it is portable code or not. – Rainer Joswig Feb 03 '21 at 07:13
  • Thanks for your comment. Unfortunately, I do not know Lisp and I am completely unable to tell if "MCL & Mac specific features" are used. I just know that I encountered a bunch of warnings and errors when trying to run it, and perhaps I was even "launching" it in a wrong way… – rfs Feb 03 '21 at 10:31

1 Answers1

5

Summary

This code is very close to being portable CL: you won't need something emulating an antique Mac to run it. I ran it on three implementations (SBCL, LispWorks, CCL) within a few minutes. However if you're not a Lisp person (and don't want to become one) it will be somewhat more fiddly to do that.

However I can't just send you a fixed version, both because this isn't the right forum for that, and also because we'd need to get the author's permission to do so. I have asked him if he would be interested in a portabalised version, and if he is, I will send him one in due course. You could also get in touch and ask to be notified.

(Meta-summary: while I think the question is fine, any reasonable answer probably doesn't fit on SO.)


Details

One initial problem with this code is that the file uses old Mac line end conventions (I think: not Unix anyway): unless whatever Lisp you're using is smart enough to spot this (some are, SBCL seems not to be although I am sure there are options to tell it) you'll need to convert it.

Given that, the code that implements this algorithm is very, very close to being portable Common Lisp. It has four dependencies on non-standard things:

  • two global variables, *save-local-symbols* and *verbose-eval-selection*;
  • two functions: choose-file-dialog and choose-directory-dialog.

The global variables can probably be safely commented out as I think they are just controls for the compiler, probably. The functions have fairly obvious specifications: they're obviously meant to pop up file / directory choosers.

However you can just not use the bits of the code that use these functions, so you can compile it, get a few compiler warnings about undefined functions, and then it's fine.

But it gets better than that in fact: the latter-day descendant of MCL is Clozure CL: CCL is free, and open source. CCL has both choose-file-dialog and choose-directory-dialog already and both of the globals exist although one is no longer exported.

Unfortunately there are then some hidden portability problems to do with assumptions about what pathnames look like as strings: it's making some assumption about what things looked like on pre-OSX Macs I think. This kind of problem is easy but often a bit fiddly to fix (I think in this case it would be easy). So, again, the answer to that is just not call the things that are doing a lot of pathname munging:

> (ps13-test-from-file-list (directory "~/Downloads/d/*.opnd"))

[... much output ...]

Total number of errors = 81.
Total number of notes = 41544.
Percentage correct = 99.81%

nil

Note that the above output came from LispWorks, not CCL: CCL works just as well though, as will any CL probably.

SBCL has one additional problem: the CL-USER package in SBCL already uses a package which exports int which is defined in this code. So you need to compile it in some other package. But given that, it's fine in SBCL as well.

  • Wow! Thank you very much for this detailed answer! Yes, I would like to be notified if you get a positive answer from the author to make this code portable (in fact, I was on the verge of asking him myself). For my information, which forum would have been better for this question? – rfs Feb 03 '21 at 14:36
  • @rfs: OK, I've mailed him and if he replies we can then get in touch via him I guess. I misworded my 'not right for SO' comment (changed now): I think the *question* was fine, it's just that my answer (which you could not have known!) doesn't really fit. Sorry: I wasn't meaning to imply you chose the wrong place to ask! –  Feb 03 '21 at 14:47
  • @rfs: there's now a pending pull request to [his repo](https://github.com/chromamorph/pitch-spelling-lisp), which has some portability fixes. However note that there are more recent versions of the `ps13` algorithm in, I think, Java, and you might want to run those instead, if your aim is research rather than playing with Lisp. –  Feb 05 '21 at 14:58