Tuesday, November 21, 2017

Python map()

You can apply a function f(x) on each element of a list A using the built in function map()

def f(x):
   return x**2 =1


A = [ 1, 2, 4, 0, 11, 10]

B = map(f, Z)


This gives an interesting idiom

C = map(int, raw_input().strip().split())

this takes space separated integers as input and stores in C.

Monday, March 20, 2017

Determining the keysignature from the standerd music notation

Key Signatures

To help understand and remember key signatures, a chart called the circle of fifths can be used. On the outside are the major key names, separated by fifths. On the inside are the corresponding minor key names. In the middle is the number and position of the sharps or flats.
Circle of Fifths
There is a little trick to figuring out a key signature's name. When confronted with a key signature that consists of flats, look at the flat second from the far right. This flat is on the line or space the key signature is named after. One flat is F, since you can't go to the next -to-last flat. To find the name of a key signature with sharps, look at the sharp farthest to the right. The key signature is the note a half step above that last sharp.
Key signatures can specify major or minor keys. To determine the name of a minor key, find the name of the key in major and then count backwards three half steps. Remember that sharps and flats affect names.


Saturday, March 11, 2017

setup midi keyboard to Ubuntu

http://askubuntu.com/questions/19764/how-does-one-set-up-a-midi-keyboard

K I figured out the smallest number of steps to get this midi keyboard working:

  1. Install qsynth Install qsynth http://hostmar.co/software-small, Jack Control (called qjackctl) Install qjackctl http://hostmar.co/software-small, and download Claudio_Piano.rar from here, unpack and save in a handy place.
  2. Launch Jack Control (Applications > Sound and Video > JACK Control on older Ubuntu versions, or search for it in the Dash in newer Ubuntu versions)
  3. Click the settings button on the right side of the Jack Control panel, in the settings switch on midi input by going into the MIDI Driver drop down near the bottom of the window and selecting seq (alsa sequencer) and click OK.
  4. Load Qsynth, go into the setup, check Enable MIDI Input and turn the midi driver to alsa_seq, in the audio tab ensure the Audio Driver is set to jack, in the sound fonts tab open your downloaded sound font from above. Click ok and reset the server when it asks.
  5. If Qsynth freezes, unfreeze by stopping the jack server and then starting it again.
  6. Go back into the JACK Audio Connection Kit window and click Connect, here we are going to make sure in the Audio tab that qsynth is connected to the system output (drag handles).
    connect qsynth to output
    In the Alsa tab we are going to connect our midi device to qsynth.
    connect midi to qsynth
  7. Back in Qsynth Click on the Channels button and watch carefully all the little lights beside each of the midi channels. Press keys on your keyboard and see which one lights up. Click on that row and set the name to Piano (or whatever your musical instrument is)
  8. Play keyboard with sound output.