ABCplayerCodea - play music in your project

Hi @veeeralp, what iPad are you using? When did it crash and what was on the screen? It won’t play an mp3.

Hey. Do I need to create the instruments of the song?
I am trying to play this song file converted from MIDI with MidiZyx2abc_1.08:
http://db.tt/vZxZyozr

But it echoes this error:

error: error: [string “–ABCMusic class by Fred Bogg…”]:166: attempt to perform arithmetic on local ‘denominator’ (a nil value)

I am using the ABCMusic class version from CargoBot in Codea 1.4.3
Thanks for this great tool!

Hi @juaxix, thanks! I’m looking through your tune now and have got parts of it going. Watch this space.

First thing, try using the most recent version which can be found on GitHub at the link at the top of the thread. It has got the ability to change sounds, but rudimentary.

You can avoid escape codes by using double square brackets to enclose the tune text.

And it would be best to replace the
characters with new lines.

The different instruments will need extracting, as I haven’t fully implemented multivoicing.

I’ll post again when it’s working with your tune!

Have you thought of a simple series of regular expressions to format the text that the conversor prints?

@Fred I’m using an iPad 2 16 GB. It crashed when it said loading on the screen and the delta time freezes at 0.04 seconds. I’m probably just copying it wrong. Any help?

Hi @juaxix, yes, I have listed them in the thread above somewhere, but you won’t need to escape the ’ if you use double square brackets.

Hi @veeeralp, does it freeze ? How long did you let it run for? The default song is quite long…

Wow @juaxix, that tune is very complex. I’ve made a few changes as a result, but it will be a while until I get it playing nicely.

Double post deleted.

Wow thanks you for all the effort!..dont take it so serious, it is just a test, the midi comes from a movie…

That’s ok, it’s a way of extending it and fixing bugs! By the way, in the MidiZyx thing you should tell it what key the music is in, otherwise when we try to play it the notes are wrong. When I changed the key to A rather than C it began to be recognisable… :slight_smile:

Now I recognise it, @juaxix, it’s the one where the boat sinks, right? :slight_smile: I changed the key to E and the wrong notes went away. That’s the bit in your ABC tune that starts with K:

The code on GitHub (see top of thread) will now play at least the piano bit ok. The problem is the ABC tune output from MIDIzyx2ABC is a bit mangled. Not all MIDI Files convert well. For multiple voicing, you will need to break each bit out and put them as separate tunes. Play them simultaneously with different instruments like I demonstrate in Main().

Thanks for the challenge, but I admit there is a long way to go before this works easily… :slight_smile:

I think I’m being incredibly dense here, but I’m having trouble wrangling ABCMusicPlayer. I tried looking through the code in CargoBot as an example, but in that project the music player has been wrappered in additional classes, and a good chunk seems to have been commented out. I’m having trouble with just the basics of feeding the class and playing a tune within the structure of a program.

Is there a simple example program that shows how to add a music player, initialize a tune, set the various values for LOOP, etc?

Thanks for all your work in this. I can see that it’s not an easy piece of code by any measure.

Dont know it is any help, but I ripped out the note calculations from the player for a project I started on. The idea was using physical objects that was created by sound, but haven’t done much more than a small animation.

https://gist.github.com/4707774

Thanks, @tnlogy, that’s helpful in seeing how the notes are shaped, and I think it’ll help me in some of my sound effects.

But I’d still like to see a program that just creates an instance of ABCMusic, loads in a tune, and plays it back. I can’t even figure out what the range of values is for some of the required init fields (LOOP, for example). I know it should be dead obvious, and probably is if I wasn’t looking at it with the wrong set of preconcieved ideas, but it’s just not clear to me where to begin.

Hang on… the version of ABCMusic I was using was the one from CargoBot, which appears to have been modded to meet the needs of that code. Looking at the original gist, the code looks much more straightforward and the comments inform me of the values needed.

I should have been smart enough to head for the gist earlier. My apologies.

Hi @Mark, yes it was developed beyond what was used in CargoBot, so the GitHub version should be easier to start with. Granted, the code is a bit of a mess. :slight_smile: LOOP should be a 1 or 0 flag to determine whether to loop the tune. Has been a long time since I looked at te code though! Let me know how you go, I would be more than happy to return to it if you need. Cheers!

Can anyone recommend a nice app on the Mac (or better yet, iPad) for composing ABC format music? I’m putting the final touches on a game for the store, and the biggest remaining task is a couple of original background tunes.

I found MidiZyx2abc was the best. You can either start with a MIDI file or type the score out in ABC format. It will convert it to traditional score as you go which is good if you read music. Complex MIDI files do not always convert nicely… But if you have one you love let me now and I can give you a hand.

http://www.midicond.de/Freeware/index_en.html#MidiZyx2abc

@Fred, in your opinion, what’s the best ABC composing software for PC?