poetizer – THE HYPERTEXT http://www.thehypertext.com Thu, 10 Dec 2015 06:10:15 +0000 en-US hourly 1 https://wordpress.org/?v=5.0.4 General Update http://www.thehypertext.com/2014/09/29/general-update/ http://www.thehypertext.com/2014/09/29/general-update/#comments Mon, 29 Sep 2014 06:24:41 +0000 http://www.thehypertext.com/?p=177 I've been so busy the past two weeks that I failed to update this blog. But documentation is important, and that's why I'm going to take a moment to fill you in on all my recent activities. This post will cover all the projects I've been working on.

Read More...

]]>
I’ve been so busy the past two weeks that I failed to update this blog. But documentation is important, and that’s why I’m going to take a moment to fill you in on all my recent activities. This post will cover all the projects I’ve been working on, primarily:

  • Applications Presentation on September 16
  • ITP Code Poetry Slam on November 14
  • The Mechanical Turk’s Ghost
  • Che55

On Tuesday, September 16, I helped deliver a presentation to our class in Applications. Yingjie Bei, Rebecca Lieberman, and Supreet Mahanti were in my group, and we utilized my Poetizer software to create an interactive storytelling exercise for the entire audience. Sarah Rothberg was kind enough to record the presentation, and Rebecca posted it on Vimeo:

 

 

I’ve also been organizing an ITP Code Poetry Slam, which will take place at 6:30pm on November 14. Submissions are now open, and I’m hoping the event will serve as a conduit for productive dialogue between the fields of poetry and computer science. Announcements regarding judges, special guests, and other details to come.

Various explorations related to the Mechanical Turk’s Ghost [working title] have consumed the rest of my time. While I wait for all the electronic components I need to arrive, I have been focusing on the software aspects of the project, along with some general aspects of the hardware.

The first revision to the preliminary design I sketched out in my prior post resulted from a friend‘s suggestion. Rather than using conductive pads on the board, I now plan to use Hall effect sensors mounted beneath the board that will react to tiny neodymium magnets embedded in each chess piece. If everything works properly, this design should be far less visible, and thus less intrusive to the overall experience. I ordered 100 sensors and 500 magnets, and I look forward to experimenting with them when they arrive.

In the meantime, the parts I listed in my prior post arrived, and I was especially excited to begin working with the Raspberry Pi. I formatted an 8GB SD card and put NOOBS on it, then booted up the Raspberry Pi and installed Raspbian, a free operating system based on Debian Linux that is optimized for the Pi’s hardware.

r_pi

The Stockfish chess engine will be a major component of this project, and I was concerned that its binaries would not compile on the Raspberry Pi. The makefile documentation listed a number of options for system architecture, none of which exactly matched the ARM v6 chip on the Raspberry Pi.

Screen Shot 2014-09-28 at 10.46.18 PMFirst, I tried the “ARMv7” option. The compiler ran for about 10 minutes before experiencing errors and failing. I then tried several other options, none of which worked. I was about to give up completely and resign myself to running the chess engine on my laptop, when I noticed the “profile-build” option. I had never heard of profile-guided optimization (PGO), but I tried using the command “make profile-build” rather than “make build” along with the option for unspecified 32-bit architecture. This combination allowed Stockfish to compile without any issues. Here is the command that I used (from the /Stockfish/src folder):

$ make profile-build ARCH=general-32

With Stockfish successfully compiled on the Raspberry Pi, I copied the binary executable to the system path (so that I could script the engine using the Python subprocess library), then tried running the Python script I wrote to control Stockfish. It worked without any issues:

ghost

My next set of explorations revolved around the music component of the project. As I specified in my prior post, I want the device to generate music. I took some time to consider what type of music would be most appropriate, and settled on classical music as a starting point. Classical music is ideal because so many great works are in the public domain, and because so many serious chess players enjoy listening to it during play. (As anecdotal evidence, the Chess Forum in Greenwich Village, a venue where chess players congregate to play at all hours of the day and night, plays nothing but classical music all the time. I have been speaking to one of the owners of the Chess Forum about demonstrating my prototype device there once it is constructed.)

Generating a classical music mashup using data from the game in progress was the first idea I pursued. For this approach, I imagined that two classical music themes (one for black, one for white) could be combined in a way that reflected the relative strength of each side at any given point in the game. (A more complex approach might involve algorithmic music generation, but I am not ready to pursue that option just yet.) Before pursuing any prototyping or experimentation, I knew that the two themes would need to be suitably different (so as to distinguish one from the other) but also somewhat complementary in order to create a pleasant listening experience. A friend of mine who studies music suggested pairing one song (or symphony or concerto) in a major key with another song in the relative minor key.

Using YouTube Mixer, I was able to prototype the overall experience by fading back and forth between two songs. I started by pairing Beethoven’s Symphony No. 9 and Rachmaninoff’s Piano Concerto No. 3, and I was very satisfied with the results (play both these videos at once to hear the mashup):

I then worked on creating a music mashup script to pair with my chess engine script. My requirements seemed very simple: I would need a script that could play two sound files at once and control their respective volume levels independently, based on the fluctuations in the score calculated by the chess engine. The script would also need to be able to run on the Raspberry Pi.

These requirements ended up being more difficult to fulfill than I anticipated. I explored many Python audio libraries, including pyo, PyFluidSynth, mingus, and pygame’s mixer module. I also looked into using SoX, a command line audio utility, through the python subprocess library. Unfortunately, all of these options were either too complex or too simple to perform the required tasks.

Finally, on Gabe Weintraub’s suggestion, I looked into using Processing for my audio requirements and discovered a library called Minim that could do everything I needed. I then wrote the following Processing sketch:

import ddf.minim.*;

Minim minim1;
Minim minim2;
AudioPlayer player1;
AudioPlayer player2;

float gain1 = 0.0;
float gain2 = 0.0;
float tgtGain1 = 0.0;
float tgtGain2 = 0.0;
float level1 = 0.0;
float level2 = 0.0;
float lvlAdjust = 0.0;

BufferedReader reader;
String line;
float score = 0;

void setup() {
  minim1 = new Minim(this);
  minim2 = new Minim(this);
  player1 = minim1.loadFile("valkyries.mp3");
  player2 = minim2.loadFile("Rc3_1.mp3");
  player1.play();
  player1.setGain(-80.0);
  player2.play();
  player2.setGain(6.0);
}

void draw() {
  reader = createReader("score.txt");
  try {
    line = reader.readLine();
  } catch (IOException e) {
    e.printStackTrace();
    line = null;
  }
  print(line); 
  score = float(line);
  
  level1 = (player1.left.level() + player1.right.level()) / 2;
  level2 = (player2.left.level() + player2.right.level()) / 2;  

  lvlAdjust = map(level1 - level2, -0.2, 0.2, -1, 1);
  tgtGain1 = map(score, -1000, 1000, -30, 6);
  tgtGain2 = map(score, 1000, -1000, -30, 6);
  tgtGain1 = tgtGain1 * (lvlAdjust + 1);
  tgtGain2 = tgtGain2 / (lvlAdjust + 1);
  
  gain1 = player1.getGain();
  gain2 = player2.getGain();
  
  print(' ');
  print(gain1);
  print(' ');
  print(gain2);
  print(' ');
  print(level1);
  print(' ');
  println(level2);
  
  if (level2 > level1) {
    tgtGain2 -= 0.1;
  } else if (level1 < level2) {
    tgtGain1 -= 0.1;
  }
  
  player1.setGain(tgtGain1);
  player2.setGain(tgtGain2);
}

The script above reads score values from a file created by the Python script that controls the chess engine. The score values are then mapped to gain levels for each of the two tracks that are playing. I input a chess game move by move into the terminal, and the combination of scripts worked as intended by fading between the two songs based on the relative positions of white and black in the chess game.

Unfortunately, a broader issue with my overall approach became highly apparent: the dynamic qualities of each song overshadowed most of the volume changes that occurred as a result of the game. In other words, each song got louder and quieter at various points by itself, and that was more noticeable than the volume adjustments the script was making. I attempted to compensate for these natural volume changes by normalizing the volume of each song based on its relative level compared to the other song (see lines 42-45, 48-49, and 63-67 in the code above). This did not work as effectively as I hoped, and resulted in some very unpleasant sound distortions.

After conferring with my Automata instructor, Nick Yulman,  I have decided to take an alternate approach. Rather than playing two complete tracks and fading between them, I plan to record stems (individual instrument recordings) using the relevant midi files, and then create loop tracks that will be triggered at various score thresholds. I am still in the process of exploring this approach and will provide a comprehensive update sometime in the near future.

In the meantime, I have been learning about using combinations of digital and analog inputs and outputs with the Arduino, and using various input sensors to control motors, servos, solenoids, and RGB LEDs:

photo 3

In Introduction to Computational Media, we are learning about object oriented programming, and Dan Shiffman asked us to create a Processing sketch using classes and objects this week. As I prepare to create a physical chessboard, I thought it would be appropriate to make a software version to perform tests. Che55 (which I named with 5’s as an homage to Processing’s original name, “Proce55ing“) was the result.

che55

Che55 is a fully functional chess GUI, written in Processing. Only legal moves can be made, and special moves such as en passant, castling, and pawns reaching the end of the board have been accounted for. I plan to link Che55 with Stockfish in order to create chess visualizations and provide game analysis, and to prototype various elements of the Mechanical Turk’s Ghost, including the musical component. I left plenty of space around the board for additional GUI elements, which I’m currently working on implementing. All of the code is available on Github.

Unfortunately, I cannot claim credit for the chess piece designs. Rather, I was inspired by an installation I saw at the New York MoMA two weeks ago called Thinking Machine 4 by Martin Wattenberg and Marek Walczak (also written in Processing).

That’s all for now. Stay tuned for new posts about each of these projects. I will try to keep this blog more regularly updated so there (hopefully) will be no need for future multi-project megaposts like this one. Thanks for reading.

]]>
http://www.thehypertext.com/2014/09/29/general-update/feed/ 2
More Poetizer Output http://www.thehypertext.com/2014/09/02/more-poetizer-output/ Tue, 02 Sep 2014 01:02:57 +0000 http://www.thehypertext.com/?p=51 I thought I'd share a few more computer poems with you. But first, a new video.

Read More & Watch the Video...

]]>
I thought I’d share a few more computer poems with you. But first, a new video:

For more information, see my previous blog entry.

Now, here are some of the best poems it has produced. This is only a small collection… I have literally thousands of poems like these:

1. by richmond
i raised my knees supine on the granite
steps of the human mind to correlate
all its contents we live on a cold winter
moony night it said that nothing ever
happened so worry its all like golden
of past puerility or past manhood and all
i raised my knees supine on the granite
crumble away batch will crumble but
crumble away batch will crumble

2. and houses
roads boulevard are as fugitive alas
as the tears blister and start you shall love
corrupt with your crooked heart it was late
late in the afternoon and it was not
meant that we were doing was right that we
hoped to change because it was not meant that
roads boulevard are as fugitive alas
and the thought of such endless avenues
and the thought of such endless avenues

3. upward lemon
yellow his belly button bud of flesh and saw
the dark universe yawning where the plot
where the walls staring forms leaned out leaning
the room the char come and go talking
of michelangelo and indeed there
will be time to get complicated messy
yellow his belly button bud of flesh and saw
cities have sprouted up along the floor
cities have sprouted up along the floor

4. never really
die it has no ending ill love you till
china and africa meet and the sensation
of pater to recreate the phrase structure
and measure of poor man prose and stand
before you dumb and intelligent
and shaking with shame rejected yet profess
out the time and if it rains a closed circuit

5. nymphs of
depths infinity around the limp leaves
waited for rain while the black planets roll
without aim where they roll in their whirlpools
strange dolphins and sea nymphs of depths eternity
around the limp father of thou
dreamy floating flower ugly and futile
lean neck and shrieked with delight in for committing

6. with a
dulcimer in a formulated phrase
and when i count there are only you and
i have seen the perpetual footman hold
my coat and snicker and in the mountains
in the wad but dry sterile thunder
without rain there is one thing its a dream
already ended nothing

7. me hitting
the period and you know nothing do
you think the emptiness of space which is
the end grant to aristotle
what we have lingered in the subway window
jumped in limousines with the imaginary

8. party is
stuck on a pin when i and i thought i
was fishing in the middle things have had
time to devise a face to meet the faces
that you were there and alive in their hearts
who lit cigarettes in boxcars boxcars

9. troubles me
for i can connect nothing with nothing
the broken fingernails of soil hands
my citizenry humble people who expect
null la la to carthage then i came
to your metropolis walked market street singing

10. of them
is being smeared on the far arctic isle
oh great was the sin of my hands queen and
her tribe courier stars doctor back from
his hansen's disease and woe ships of pure air
inconceivable for me to betray even
the ism can disperse through the
wall and i know this from staring at mountains

11. being depressed
on a ledge halfway up the white hair of
the intrinsic mind that these cockle of
birth and death and back turn upward from the
sky with monuments span the bay then up
the mountain and the climbing party is
stuck on a bare stage as the years in did
khan a stately pleasure dome with caves

12. like the
action of the high water mark that place
where the action of the hoary primordial
grove where the sun goes down and wept sweet thames
run softly till i end my song sweet thames river
run softly till i end my birdsong the river
into the heart of the blind where mass and
gravity bulk vast its centrifuge

13. cardboard boxes
butt ends or other testimony
of summertime nights the nymphs are departed
sweet thames run softly for i have lived over
my lives without number i have whirled with
the fanciful idea of
a toast and tea in the colonnade and
went leaving no broken hearts who sang sweet

14. will show
you fear in a cage and can see at the
air murmur of maternal who are mad
to talk mad to live mad to talk mad to
be the first word of paradise lost on
an empty page think of an animal
is being tortured with electric while
android pope this is the lady of situations

15. dear mrs
enjoin her i bring the horoscope myself
one must be drooping and shedding her dims
on the final stanzas of gibberish
who cooked rotten creature lung heart feet
tail and tortillas dreaming of as i
need be found in our true blissful essence
of mind is pure machinery whose blood

16. in the
form of my spirit and great is the merchant
and this and this is early on years before
the machinery of other things of things
more foreign and more distant in space and in
realms where the glass held up by standards wrought
with vines from which a minute there is not
even another individual who is herself
clinically depressed person can not get
straight you are thinking think i think we are
efflorescence all sorts of shapes and smells and after
that long kiss i near lost my intimation yes he
said i blaspheme i cant bear to look at you
and me would it have been the same you are
behind bars you are in the earth at the
romance of the wards of the king must die
unheard in dim song of my hands queen and
her only i cant bear to look so antique
and her presence the monition of
her heart but for her lips roses from the
superhuman tomb

17. ate the
lamb stew of the east pilgrim states and halls
bickering with the thing that troubles me
for i should have been the rats foot only
year to year but at my back in a brown
mantle hooded i do i shall wear white
flannel trousers and walk the street danced on
broken barefoot smashed record player records
of nostalgic european high german
jazz finished the whisky and threw up groaning
into the middle sixties was a soft
october night curled once about the sky
a hat on a million times the fool i
grow previous i grow old i shall wear the bottoms
of my natural ecstasy whom i sit
on her back o look in the sand if there
were water we should voyage far the sciences
each straining in its spore like the andalusian
girls used or shall i at least pretend to
be of use suave cautious and meticulous
full of depressed affected role is coming

18. the sacred
river ran on i saw your saints your zens
athenians and though the west wind appear
to harbor there not one pure dream of love
the dictates of her aspect her indeterminate
response to question her potency
over sewer water and waters her power
to to mortify to invest with lulu
to render mad to incite
gong o let not time deceive you you can
not get drunk and you closing the book spread
like an infective disease from city
to metropolis from continent to continent
barred out here attach there denounced
by press and stump censured even by
the eleemosynary spider or under
seals broken by the hole in the ocean
of mercator projection its in marshes
faded stagnant pools in the colonnade
and went on a bare stage as the writer
as the writer has cursed the world

19. [untitled]
shriek come the break of day being driven to
madness with fright i have haunted the tombs
of the wards of the low on whom assurance
sits as a silk hat on a screen would it
have been as often of the band and blew
the suffering of the states naked
mind for love was the color of television

20. regiments of
fashion and the deep waters of the subway
and were red eyed in the trench of the heterosexual
dollar the one universal essence
of purest poison lurked the very good
and the dying and the lore of ocean
blue green grey white or black smooth prance or
mountainous that ocean is more ancient
than the healthy then too still american
television is full of high sentence
but a bit dumb at times indeed almost
ridiculous almost at times indeed
almost nonsensical almost at times
indeed almost idiotic almost
at times indeed almost farcical
almost at times indeed almost ridiculous
almost at times the utter casualness
and deep ignorance of it and in iowa
i know this from staring at raft months
on end they never quite shine and the tanked
up clatter of the stability

21. no explanation
no mix of words or euphony or memories
can touch that sense of the globe its ubiquity
as constituting percent of the true
predator the great white shark of pain that
here was literally take up away by something
unnamed until only a void was left
the knowledge that the hyades shall sing
where flap the tatters of the skull who
humourless protest overturned only
one emblematic pingpong table resting
briefly in returning class later truly
bald except for a hundred visions and
revisions which a golden peeped out another
hid his eyes before his feet flowed up the
earth take heed scraped and scraped look again at
that time remembrance of a whole generation
comes to a sea journey
atone im with you in rockland where you
scream in a long face its them pills i took
to bring it off she said something

22. their wrists
three fourth dimension successively unsuccessfully
gave up all for what everything comes down
to the three old of fate the one eyeball of
the blind where mass and gravity bulk brobdingnagian

]]>