NaNoGenMo / 2018

National Novel Generation Month, 2018 edition.
https://nanogenmo.github.io/
112 stars 6 forks source link

Music to prose conversion #10

Open enkiv2 opened 5 years ago

enkiv2 commented 5 years ago

This is going to be my 'gimme' novel this year.

Sound has frequency and words have frequency -- and both music and rhetoric use repetition -- so why not perform a conversion? Specifically, I'm planning to take midi files of existing & well-known songs, convert each note into a frequency, and then substitute it with the word whose frequency rank is the same as the note's frequency in hertz.

(I may or may not adjust by 20. Human hearing range is approximately 20Hz-20kHz, and while the top 20 most common words are extremely boring, music very rarely sits on the border of infrasound.)

Open questions: should I treat each voice as a separate stream entirely, make them parallel (with some kind of formatting), or somehow combine them (with an average, or a sum, or maybe combined with word2vec)?

Tools: midi2csv, a list of the 20,000 most common english words, maybe a table of notes to frequencies (in case I somehow have trouble with calculating scales).

kleer001 commented 5 years ago

Very interesting! Are you going to make allowances for the exponential aspect of human perception of sound? I'm not entirely sure what that means, haha, but maybe just some fuel for the fire.

Since you asked, my initial impulse is to think the voices separate. Maybe even compile them measure by measure in alternating paragraphs or side by side in columns.

enkiv2 commented 5 years ago

People percieve sound volume in a logarhythmic way, but I'm not planning to encode volume. (I guess I could with font size or something, if I was generating formatted text. Formatted text tends to be harder to word-count & often won't fit / load properly from a git repo, though.)

Since I'm working with frequencies rather than notes, I'm absolutely encoding the way a note is double the frequency of the same note in the previous octave in most tunings. Of course, in a sense, I'm double-encoding that: word frequency has a zipf distribution but I'm using a frequency-ranked list rather than a set of frequencies adjusted to make the maximum 20k, so rather than chosing a word that has the same frequency as the note I'm choosing a word whose rank is the same as the frequency of the note. Basically, if you wanted to reverse the process (although you'd be missing some information) you'd have two exponential terms.

(If this ends up seeming too wild, maybe I'll get rid of the rank & compute raw frequencies based on an ebook corpus or something.)

On Thu, Oct 18, 2018 at 5:33 PM kleer001 notifications@github.com wrote:

Very interesting! Are you going to make allowances for the exponential aspect of human perception of sound? I'm not entirely sure what that means, haha, but maybe just some fuel for the fire.

Since you asked, my initial impulse is to think the voices separate. Maybe even compile them measure by measure in alternating paragraphs or side by side in columns.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NaNoGenMo/2018/issues/10#issuecomment-431171018, or mute the thread https://github.com/notifications/unsubscribe-auth/AAd6GQOJC3jJwJ4KdVXYQkyTep83A43fks5umPOmgaJpZM4Xcyx- .

enkiv2 commented 5 years ago

I jumped the gun & implemented this, though I haven't generated a whole book yet.

The result is repetitive but evocative:

unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt trust die sleep his give those hurt unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt sleep die party his give those unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt trust die sleep his give those hurt unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt sleep die party his give those die sleep weren't unless too work every somebody touch unless weren't work understand hope wants unless weren't sleep his give those hurt weren't sleep die give understand hurt hurt unless give hurt hurt unless sound unless sound unless sound sound unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt trust die sleep his give those hurt unless sound unless sound unless die weren't sleep party his give those every hurt party die give stop understand hurt sleep die party those every hurt

sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above care early happy these eyes find above sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above happy early live these eyes find sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above care early happy these eyes find above sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above happy early live these eyes find early happy pleasure sleep himself love quite united enemy sleep pleasure love words death sure sleep pleasure happy these eyes find above pleasure happy early eyes words above above sleep eyes above above sleep probably sleep probably sleep probably probably sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above care early happy these eyes find above sleep probably sleep probably sleep early pleasure happy live these eyes find quite above live early eyes because words above happy early live find quite above

Here's the project gutenberg word statistics version, and another version using statistics from 2006 tv show scripts, using a handful of short classical pieces.

shakna-israel commented 5 years ago

What music selection was responsible for this little demo?

I kinda expected repetition with music, as they go hand in hand.

I wonder what something more discordant would create? Like... Say the dialup tone.

enkiv2 commented 5 years ago

The sample I pasted in was Beethoven's Fur Elise -- first with the Project Gutenberg word statistics, then with Wikipedia's TV script statistics.

On Mon, Oct 29, 2018 at 7:15 PM James Milne notifications@github.com wrote:

What music selection was responsible for this little demo?

I kinda expected repetition with music, as they go hand in hand.

I wonder what something more discordant would create? Like... Say the dialup tone.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NaNoGenMo/2018/issues/10#issuecomment-434115382, or mute the thread https://github.com/notifications/unsubscribe-auth/AAd6GcS8K6WL0GO8Uc6aQknpai-ER3etks5up4wmgaJpZM4Xcyx- .

kleer001 commented 5 years ago

The result is very poetic and evocative! I feel like with some supportive structure of filler-words or nltk sentence form or such would add to its readability. Or even some smart phrasing/spacing/breaks for negative space.

Also are you considering or using the note length?

enkiv2 commented 5 years ago

I don't currently do anything with the note length or its start position (other than keeping it sorted). I was considering making tables or something, though sticking markup on individual words very quickly expands the work beyond reasonable size even when it's something simple.

Perhaps I'll give it a try once November begins. If there's some mechanism in CSS to stretch text width & height separately, I could use that to line the notes up, indicate their duration, and indicate their amplitude. That probably wouldn't be reasonable for a 50k note output, but it might be interesting for a demo.

On Tue, Oct 30, 2018 at 11:39 AM kleer001 notifications@github.com wrote:

The result is very poetic and evocative! I feel like with some supportive structure of filler-words or nltk sentence form or such would add to its readability. Or even some smart phrasing/spacing/breaks for negative space.

Also are you considering or using the note length?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NaNoGenMo/2018/issues/10#issuecomment-434350046, or mute the thread https://github.com/notifications/unsubscribe-auth/AAd6GRZ9FS_rDkMaMP-Po_fHVxnKpGzuks5uqHKpgaJpZM4Xcyx- .

enkiv2 commented 5 years ago

Hmm. OK, HTML+CSS won't be the appropriate tool for any version of this that includes duration. CSS font-stretch exists, but only controls width & only at a fairly gross granularity -- what I would want is something that can resize any word to any X an Y dimensions. So, the solution is probably to render the words as images, stretch the images, and stitch them together. That's a potentially fun project.

On Tue, Oct 30, 2018 at 11:53 AM John Ohno john.ohno@gmail.com wrote:

I don't currently do anything with the note length or its start position (other than keeping it sorted). I was considering making tables or something, though sticking markup on individual words very quickly expands the work beyond reasonable size even when it's something simple.

Perhaps I'll give it a try once November begins. If there's some mechanism in CSS to stretch text width & height separately, I could use that to line the notes up, indicate their duration, and indicate their amplitude. That probably wouldn't be reasonable for a 50k note output, but it might be interesting for a demo.

On Tue, Oct 30, 2018 at 11:39 AM kleer001 notifications@github.com wrote:

The result is very poetic and evocative! I feel like with some supportive structure of filler-words or nltk sentence form or such would add to its readability. Or even some smart phrasing/spacing/breaks for negative space.

Also are you considering or using the note length?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NaNoGenMo/2018/issues/10#issuecomment-434350046, or mute the thread https://github.com/notifications/unsubscribe-auth/AAd6GRZ9FS_rDkMaMP-Po_fHVxnKpGzuks5uqHKpgaJpZM4Xcyx- .

enkiv2 commented 5 years ago

I generated two novel-length (95k words) outputs, from Stravinsky's Rite of Spring & Firebird Suite:

https://github.com/enkiv2/misc/blob/master/nanogenmo-2018/stravinsky.md

https://github.com/enkiv2/misc/blob/master/nanogenmo-2018/stravinsky_pg.md