cpressey / NaOpGenMo

National Opera Generation Month: spend (what's left of) the month of November writing code that generates a 2.5+ hour long opera.
8 stars 0 forks source link

The Shortbread Rocketship: a Cut-Up Opera #2

Open cpressey opened 10 years ago

cpressey commented 10 years ago

In for a penny, in for a pound, I guess.

Or should that be: in for threepenny...?

cpressey commented 10 years ago

Wow. What surprises me is how much more difficult this is than NaNoGenMo. For me, at least. And I'm not entirely certain why.

I find myself saying "no, that'd be virtually unlistenable" to ideas I have. But I don't remember going "no, that'd be virtually unreadable" to any NaNoGenMo ideas. That's just a given, I suppose, and I guess I haven't made it a given yet in my mind for this.

I will note that nowhere in the rules does it say that the resulting opera has to include a score. Likewise, nowhere does it say that it has to include an audio rendition.

But it's difficult to imagine producing an opera, at the end, without at least one of those two things. (Not saying it's impossible, it just seems like it would be... quite conceptual.)

I will probably go the audio-rendition route.

cpressey commented 10 years ago

I'll also note that one point on which the rules are silent is, well, silence.

Two and a half hours seems reasonable for a performance of an opera, but a performance usually includes a certain amount of "dead time" for warming up the orchestra, rearranging the set during scene changes, throwing flowers and/or rotten tomatoes at the cast at the end, etc. And there's usually an intermission in which the audience can use the restrooms, nibble on cucumber sandwiches, and generally try to regain their wits before the next onslaught of high-brow entertainment.

I suppose the amount of silence is just another one of those difficult judgments one must make in these sorts of things.

I'm currently considering three 40-minute acts with two 15-minute intermissions in between. But one long uninterrupted continuous 2.5-hour block of music without any breaks at all (no, not even any rests) is also intruiging.

Argh. Advice that served me well during the first NaNoGenMo, adapted from NaNoWriMo, was "the important thing is to just get something out". I should probably try that here.

Don't know yet where I'll host the resulting sound file, which of course will be... unwieldy. Possibly on alonetone.

cpressey commented 10 years ago

Some modest progress... very modest...

I extracted a 2.86 second-long clip from a recording of "La Donna E Mobile", and wrote a Python script to read a WAV file and write out a WAV file that is the input file repeated for 2.5 hours. In this case, that was 3144 repetitions of this sample.

The resulting WAV file was 1.5G in size. Encoding it in OGG brought it down to a mere 548M.

I'm sure it would be a lot smaller, though, with 8000 samples per second instead of the CD-quality 44100 samples per second (which is quite frankly overkill for this old recording anyway.)

cpressey commented 10 years ago

I'll echo @moonmilk: why am I doing this.

Specifically, why did I choose the digital-audio route, and why oh why am I trying to manipulate digital audio in Python.

Just because Python can load and save WAV files does not mean it is anywhere near the best tool for the job.

On the bright side, I have found a "technique" that permits producing hours' worth of "music" that, while not exactly "listenable", at least does not make me ill to listen to.

Unfortunately, generating 40 minutes' worth takes 25 minutes, or it would if it didn't run out of memory and take down my laptop first.

I have some ideas for reducing the memory usage, but, is that really what I want to get out of NaOpGenMo? Well, we'll see. Not too late to switch to Csound (or something newer), or generating a score and/or MIDI...

cpressey commented 10 years ago

Preview posted! Here: http://alonetone.com/catseye/tracks/the-shortbread-rocketship-act-1-scene-4

moonmilk commented 10 years ago

that's actually... kind of catchy.

cpressey commented 10 years ago

Well we'll soon fix that! Er -- I mean -- you think it's catchy now? Just wait'll we add the Scott Joplin and the Portuguese books-on-tape; then, it'll be an earworm to rival Schoenberg's Op. 23!

cpressey commented 10 years ago

Another preview: http://alonetone.com/catseye/tracks/the-shortbread-rocketship-act-3-scene-z

Kind of a mistake -- didn't mean to include short samples (in this instance the "woop woop woop") in it. Not like THAT, anyway. But, uh. I might keep this approach? I don't know. It is what it is. Listen at your own peril.

ikarth commented 10 years ago

Well, this is on it's way to being a thing. What that thing is, I don't know, but it's certainly something.

It's interesting what takes it across the line from listenable to unlistenable and back again. The repeated short samples are working like that for me, cycling from a part of the texture to an overwhelming pattern and back again.

Is that a whale song in there?

cpressey commented 10 years ago

@ikarth Being a thing (of some kind) is certainly what it aspires to!

I understand what you mean about the listenability -- I found it difficult (though not outright painful, I guess) to listen to, then it kind of lets up in the middle, and comes back. It would probably be a little less difficult overall if it was pop-song-length (3 minutes) instead of opera-scene-length (8 minutes), but only because you'd know it would soon be over. (Oh, I guess I never devblogged this, but my working approach has been to generate each 40-minute act as a series of five 8-minute scenes.)

It does not contain whale song, if the debugging output of my generator is to be believed; the samples it picked there were some birdsong (the "woop woop woop") and, apparently, a flute (mostly but not entirely coincident with the birdsong; it's hard to pick out but it's kind of a droning whining sound.) The distortion is due to the extreme lo-fi-ness of the thing, which was not entirely intentional -- it's due to (a) my crappy hand-rolled downsampler which converts the original 44100 samples/sec stereo sample to 8000 samples/sec mono without any dithering (in fact, it may just be choosing the left channel and ignoring the right one...), (b) mixing them at 8000 samples/sec, and (c) using lame as the MP3 encoder, which, seeing the low-quality audio file as input, chooses equally low-quality MP3 parameters. OK, the nice thing about that is that the resulting MP3, even though it's 8 minutes long, is under 1 megabyte in size. On the other hand, the distortion is just... yeah. I still have a hard time believing that's a flute; whale song seems much more likely.

I may re-batch-convert the samples using a real converter like sox or avconv instead of my cockamamie Python script and try it again.

cpressey commented 10 years ago

The distortion seems to be entirely due to choosing 8k samples/sec for the work/output format. There's just no room in the audio spectrum (or whatever) for competing sounds in the same range to both come through, at that resolution. I've bumped it up to 16k and the audio quality is a bit less tragic. (The scripts take twice as long and use twice as much memory, but if I'm not going beyond 8 minutes at any one go this shouldn't be a problem.)

In other news, I discovered that espeak does interpret <prosody pitch="321Hz">...</prosody> tags, however:

Not that that will necessarily stop me from using it...

ikarth commented 10 years ago

Pity there aren't more open-source vocaloids.

cpressey commented 10 years ago

@ikarth There is one, called Sinsy, but... well, it's complicated (check out the resources issue if you're interested.)

As luck would have it (I do not regularly attend the opera!), I saw Idomeneo last night. It was roughly 3 hours long, not counting the intermission. And here I am, assuming there would be 2 intermissions for this generated opera that is ultimately only 2 hours long. I may feel the need to add more acts... or an overture... or... hmmmmmmmmm...

btw, here is the code: https://github.com/cpressey/The-Shortbread-Rocketship

I can't see myself having the attention span to make many more changes to it. I'm going to start it running before heading to bed tonight (it takes about 2 hours to generate, uh, about 2 hours of audio. Interesting.)

cpressey commented 10 years ago

I'm now trying to listen to what it produced last night. For the first scene, it chose the jet engine noise as the continuous background. Fitting for an opera with the word "Rocketship" in its title, I suppose...

cpressey commented 10 years ago

Somehow, I managed to listen to the whole thing! Act II Scene III was particularly painful.

About the intermissions, I decided that anyone who chooses to sit through this certainly deserves as much of a break as they can get. There also aren't many silent moments in the scenes themselves. So, it includes two 15-minute intermissions of silence, one between acts I and II, the other between acts II and III.

I uploaded the final thing to Alonetone here: The Shortbread Rocketship (2014)

On the bright side, this should make any computer-generated music I make in the future sound relatively sane in comparison...