Sunday, December 15, 2013

That's a lot of whole notes!

This has nothing to do with NLHRI, but I am totally geeking out on piano right now. Why, you ask? I recently acquired an electric piano. I was able to purchase a relatively low-end one (the Korg SP-280) because I grew up in the 1980s. What this means is that, compared to what was available then, the cheapest piano in the store (Thanks, Muncie Music Center!) felt to me like playing a real piano. With the added bonus of a built-in metronome and several different piano tones. (I ignore all the other sounds, of course. Especially the horrible "keyboard" sound which blighted my childhood.)

I decided to begin by focusing entirely on an aspect of piano which is particularly challenging to me: rhythm. To this end, I have been remaining almost entirely in C.

So far, my practice has been developing little one-off exercises that allow me to count quarter, eighth, and sixteenth notes and triplets in a variety of tempos. One interesting facet I noted, when I was reading up on this, is that articles advising you how to get better usually say something like, "start with some moderate tempo and build up your speed from there." Um....that's only half the equation, buddy.

I started out with a lot of five-finger exercises at different tempos. Ideally I was moving smoothly between counts, but unfortunately I currently find triplets quite difficult, so I have to stop before before I move into or out of them, count a measure of silence, and then resume at the new tempo, but the goal is to be able to move smoothly between any of these counts for any number of beats. I find I can reliably keep time (and keep up) between about 50 and 120 (100 for sixteenths). I look forward to extending this in both directions.

Then I decided to do some exercises that would have me traveling the entire keyboard. I've been closing my eyes where possible so that I can really learn to feel the keyboard rather than watching my fingers (as I recall doing in the past). A few exercises I've enjoyed are:

  • Begin on C1 [left hand]/C2 [right hand] and do a few 1-octave C-scales up and down. Then run up two octaves and down one, so you are now at C2/C3. Do a few 1-octave scales here. Continue up and down the entire keyboard. Repeat, this time traveling up three octaves and down 2. Etc.
  • Do an arpeggiated C-chord in triplets, beginning at C1 with the left hand, followed by a triplet beginning on C2 with the right, etc. Then do a sixteenth-note arpeg. beginning on C1 and ending on C2 with the left, followed by a sixteenth-note arpeg. from C3 to C4, etc. I find the latter much harder to while traveling the keyboard, and the last note with each hand is not as reliably C as I would like.
  • One exercises my piano teacher (many long years ago) had me do was two handed scales and arpeggiated chords. Begin at contra C (c2) and go up four octaves, then down four octaves to the original position. Repeat. Then go up two octaves and then reverse direction with the left hand for two octaves. Reverse again so hands meet where they parted, go up two and back down, part again and then rejoin, and then go back down to the original position.
  • Then, I moved on to the other aspect which has always bedeviled me: two fingers at a time. In other words, depress C/E with fingers 1/3, then release while simultaneously depressing D/F with 2/4, release and depress D/G with 3/5, and then reverse. Unless one of the fingers is the thumb, I struggle to press the two fingers absolutely simultaneously unless I'm going reeeeeeeeeeeally slowly. So that's what I did: whole notes and half notes at 60. For like, 10 minutes. That's a lot of whole notes and half notes!

    Sunday, April 28, 2013

    Loops in LaTex: from the "High Time" Department

    Something I have done a billion times is take a basic list, then repeat it x times, each time coloring one item on the list, followed by slides that expand on the colored item. So it's high time I learned to do this programmatically! This uses the forloop package:

    \newcounter{ctr}
    \forLoop{1}{3}{ctr}{
    \begin{frame}
    \begin{itemize}
    \item {\ifnum\thectr=1\color{red}\fi Dependency Parsing}
    \item {\ifnum\thectr=2\color{red}\fi Situatedness}
    \item {\ifnum\thectr=3\color{red}\fi Vision Both Directions}
    \end{itemize}
    \end{frame}

    \ifnum\thectr=1 {
    \begin{frame}{Dependency Parsing}
    \end{frame}
    }
    \fi

    \ifnum\thectr=2 {
    \begin{frame}{Situatedness}
    \end{frame}
    }
    \fi

    \ifnum\thectr=3 {
    \begin{frame}{Vision Both Directions}
    \end{frame}
    }
    \fi

    }
    <\code>

    Monday, March 25, 2013

    HTK Tutorial Steps 3 and 4. Am I done now? I think I'm done.

    For Step 3, recording the data, I couldn't figure out how to make HSLab use my mic as input, so I used audacity, following that voxforge tutorial again.

    For Step 4, I was able to return once again to the HTKBook, but I got the following error:

      ERROR [+6313]  OpenParmChannel: cannot read HTK Header in File /Users/rcantrel/SR/htk/train/wav/sample14.wav
      ERROR [+6313]  OpenAsChannel: OpenParmChannel failed
      ERROR [+6316]  OpenBuffer: OpenAsChannel failed
      ERROR [+1050]  OpenParmFile: Config parameters invalid
     FATAL ERROR - Terminating program HCopy


    I ended up having two config files, my main one, config:

        SOURCEFORMAT = WAV
        TRACE = 1
        MICIN = T


    (those are tabs that begin each line)

    and a second one, hcopy.config:

    TARGETKIND = MFCC_0
    TARGETRATE = 100000.0
    SAVECOMPRESSED = T
    SAVEWITHCRC = T
    WINDOWSIZE = 250000.0
    USEHAMMING = T
    PREEMCOEF = 0.97
    NUMCHANS = 26
    CEPLIFTER = 22
    NUMCEPS = 12
    ENORMALISE = F


    where the configuration values are at the beginning of the line. The important point is that SOURCEFORMAT = WAV in the main config file. Otherwise, it assumes the input files are .htk files. I don't even know what those are, so I'm pretty sure I don't want to use them.

    I set the main config file using:

    export HCONFIG=/path/to/config

    and the final HCopy command was:

    HCopy -T 1 -C hcopy.config -S dt.plp.list

    HTK Resources:

    list of HTK errors

    guy blogging his progress through tutorial (just like me!)

    Traversing the HTK Tutorial: A Comedy of Errors

    1. Create a grammar, which can then be visualize a word network:

    Pillar-of-Autumn:SR rcantrel$ HParse gram wdnet
    Segmentation fault: 11



    Gr.... I verified using trace (-T 1) that it is reading the grammer:

    Pillar-of-Autumn:SR rcantrel$ HParse -T 1 gram wdnet2
    Creating HParse net from file gram
    Generating Lattice with 5 nodes and 4 links
    Writing Word Lattice to wdnet2
    Segmentation fault: 11


    Just to check what happens with an erroneous dictionary, I deleted a semicolon:

    Pillar-of-Autumn:SR rcantrel$ HParse -T 1 gram wdnet2
    Creating HParse net from file gram
      ERROR [+3130]  PVariable: Variable digit is undefined
     FATAL ERROR - Terminating program HParse


    Fine, I decided to move on. (To be clear, that's the short (very short) version of how I decided to move on.)

    2. Create the dictionary:

    They have a set of steps that I can use to create my wordlist from sentences, but I decided to strip this one down to its essentials. Emotionally, I needed a win, and I was determined to get one. So I created a tiny dictionary:

    ONE

    I downloaded the beep dictionary. After several trials, realized that I needed to sort the dictionary in dictionary order:

    Pillar-of-Autumn:SR rcantrel$ sort -d beep/beep-1.0  > beepsorted3
    Pillar-of-Autumn:SR rcantrel$ HDMan -m -w wlist -l glorp test beepsorted3
    Pillar-of-Autumn:SR rcantrel$
    Okay, that was disturbingly silent...

    Sure enough, even though the beep dictionary contained all the words in my wordlist, it couldn't find a single one!

    Missing Words
    -------------
    ONE

    Dictionary Usage Statistics
    ---------------------------
      Dictionary    TotalWords WordsUsed  TotalProns PronsUsed
     beepsorted3         0          0          0          0
            test         0          0          0          0

    1 words required, 1 missing


    Dictionary test created


    At this point, I decided to move on...to brownies. Yummy delicious brownies. Then, while enjoying brownies, I discovered that the beep dictionary format isn't correct. I downloaded voxforge lexicon (Thanks, htk julius tutorial!) and I had my win in the form of a dictionary:

    ONE             [ONE]           w ah n sp

    Friday, March 22, 2013

    Installing HTK on OS X

    I already read a blog post about this (Thanks, Patrick O'Keefe!) but my experience was different enough that I decided to briefly post.

    I had to do a number of things to the ./configure line. Like POK, I had to add:

    -build=i686-apple-macos

    and

    CFLAGS=-I/usr/include/malloc

    I also had to identify my X11 library and headers:

     LDFLAGS=-L/opt/X11/lib CFLAGS=-I/opt/X11/include

    Now, for some reason the first time I got it to work, I had multiple CFLAGS arguments and it worked fine:

    ./configure -build=i686-apple-macos LDFLAGS=-L/opt/X11/lib CFLAGS=-I/opt/X11/include  CFLAGS=-D'ARCH="darwin"' CFLAGS=-I/usr/include/malloc

    The second time, however, that failed, and I figured out that I had to consolidate them:

    ./configure -build=i686-apple-macos LDFLAGS=-L/opt/X11/lib CFLAGS='-I/opt/X11/include -I/usr/include/malloc'

    Still haven't figured out why it appeared to work the first time. It's possible I manually edited the makefiles and then forgot, but I really don't think so.

    Now, about that D'ARCH="darwin"...

    For some reason, everything else was working but HTKLib/HGraf.c was complaining that it contained the variable ARCH which it had never heard of. The installation info on the HTK download site showed that variable being automatically set, but I couldn't get it to work; I actually had to go into HTKLib/HGraf.c and change variable ARCH to string "darwin". Not good to have to do that, but it seemed to get me up and running, so I'm happy as long as I remember how to do it next time...hence this blog post :)

    So now I'm back to happily working through the tutorial in HTKBook...oh goodie. My first grammar-related seg fault. :D

    Wednesday, May 9, 2012

    Flight tracking

    As I prepare to head to Bielefeld for summer research, a young woman's fancy turns lightly to the thought of getting the lowest airfare possible. How long should I wait? I've heard that at 21 days out, prices start dropping as airlines try to fill seats. I've been looking for my ticket for a while, and so far I've seen no evidence of a significant change either way around 21 days. I more rigorously searched fares manually one day and noticed that a quite significant drop may actually occur around day 14. But that seems like it's cutting it awfully close...How can I be sure? Was that one day just a fluke?

    Step 1: Search Expedia automatically for the lowest fare available for my point-of-origin/destination starting with 1 day out (tomorrow) up until my actual day of departure (the 28th). Wow, that's only 19 days. I'm cutting it close regardless... (Don't worry, while my evidence on the 14-day drop is equivocal, I've seen no evidence whatsoever that the last-minute price rise occurs before 7 days out, and most likely occurs about 3 or 4 days out.)

    #!/usr/bin/python                                                                                          

    import os

    departuremonth="05"

    i=9
    while (i<=28) :
        departureday=str(i)

        cmd = 'curl http://www.expedia.com/Flights-Search?trip=roundtrip\&leg1=from:Indianapolis,%20IN,%20Unite\
    d%20States%20%28IND-Indianapolis%20Intl.%29,to:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,departure:'+\
    departuremonth+'%2F'+departureday+'%2F2012TANYT\&leg2=from:Frankfurt,%20Germany%20%28FRA-All%20Airports%29,\
    to:Indianapolis,%20IN,%20United%20States%20%28IND-Indianapolis%20Intl.%29,departure:08%2F03%2F2012TANYT\&pa\
    ssengers=children:0,adults:1,seniors:0,infantinlap:Y\&options=cabinclass:coach,nopenalty:N,sortby:price\&mo\
    de=search > relly3'

        os.system(cmd)

        resultsfile = file("relly3",'r')
        lines = resultsfile.readlines()
        for line in lines:
            if line.find("formattedLowestPrice")!=-1:
                removeKey="formattedLowestPrice\">"
                removefrom=line.find(removeKey)+len(removeKey)
                line=line[removefrom:]
                removeto=line.find("<")
                line=line[:removeto]
                print departuremonth+"-"+departureday+"-12: " + line

        i+=1