Kara-Moon Forum

Developers & Technology => Musical MIDI Accompaniment (MMA) => Topic started by: bvdp on May 05, 2020, 09:01:51 PM



Title: MMA 2002c online
Post by: bvdp on May 05, 2020, 09:01:51 PM
A new release to beat on:

  https://www.mellowood.ca/mma/downloads.html#developer

Lots of nice little fixes and features. See the web page for details.


Title: Re: MMA 2002c online
Post by: sciurius on May 06, 2020, 09:09:41 AM
Good job. A small problem, though...

You use tempfile.mkstemp, which creates a temp file. Then you use the name for output file. This will be opened later, and since the temp file already exists MMA generates a message:

Overwriting existing midi file (12 bars, 0.40 min / 0:23 m:s): '/tmp/MMA_1t45x9r1.mid'

If you do not want to use tempfile.mktemp (for good reasons) it may be worth to consider something similar to:

    f = tempfile.NamedTemporaryFile(prefix="MMA_", suffix=".mid")
    outfile = f.name
    f.close            # file will be deleted


Should some complain that the output file is opened twice, you can blame python ;) .


Title: Re: MMA 2002c online
Post by: sciurius on May 06, 2020, 09:11:46 AM
RPMs for Fedora and others in the usual place:

https://www.squirrel.nl/pub/MMA/


Title: Re: MMA 2002c online
Post by: bvdp on May 06, 2020, 04:01:20 PM
Good job. A small problem, though...

You use tempfile.mkstemp, which creates a temp file. Then you use the name for output file. This will be opened later, and since the temp file already exists MMA generates a message:

Overwriting existing midi file (12 bars, 0.40 min / 0:23 m:s): '/tmp/MMA_1t45x9r1.mid'

If you do not want to use tempfile.mktemp (for good reasons) it may be worth to consider something similar to:

    f = tempfile.NamedTemporaryFile(prefix="MMA_", suffix=".mid")
    outfile = f.name
    f.close            # file will be deleted


Should some complain that the output file is opened twice, you can blame python ;) .

Yes, I think the problem with all this: mkstemp() only opens for read, not "rwb". But let look when I get back in a few days ... gotta wedding to go to :)