VCR’s are analog TV transmitters

Any VCR with antenna output has a built-in RF modulator.

Generally they transmit on channels 2-4. Here are the US frequencies:

from wikipedia http://en.wikipedia.org/wiki/Television_channel_frequencies

The signal is weak, not intended for broadcast. Not legal to broadcast… but hypothetically, amplifiers and antennas could be connected.

This audio signal is from an iPod playing through a VCR received by rtl-sdr in Max on 65.75 MHz. (channel 3) using a random length wire connected to the antenna output.

 

Notes about RF modulators:

I have tried this with some small RF modulator boxes. One of the problems is that you need to send a signal to the video input, or the modulator won’t run. You can get a rough signal by patching one of the audio channels into the video input jack. Or a better signal by using the video composite output of a raspberry-pi. Although the VCR gives a much cleaner signal

Stock market music in Max

Make music from the motion of stock prices.

This program gathers stock prices into a database. It generates Midi data – mapping price to pitch, and mapping trading volume to velocity and rhythmic density. It uses ancient Web technology: HTML/javascript front-end with a php back-end accessing a mysql database.

Case study: http://zproject.wikispaces.com/stock+market+music

To run this project, you will need a server (preferably linux) with the following capabilities:

  • mysql + phpmyadmin
  • php (and ability to run php over the web)
  • netcat (nc)
  • network access

All of this is pretty standard – so I won’t talk about it here. I am running it on Ubuntu Linux. There are many other ways to get the project working, by using the layout described here.

download

https://github.com/tkzic/internet-sensors

folder: stock-market

files

Max

stock_market_music.maxpat

HTML/javascript web client
  • newstock3.html: (web page interface)
  • selectstock3.js:  (front-end)
php server
  • getstock3.php (back-end server to get quotes and save them to a database)
  • play3.php: (back-end server to retrieve quotes, analyze, and map to Midi sequence to send to Max)
  • udp.php: Osc library
Set execute privileges on php files so they can be run from your web server. (chmod +x)

 

database

The selectstock3.php program harvests stock quote data and stores it in a mysql database.

The database name is:  stocks – table is: quotes

Table structure:

The table is basic flat representation of a stock quote, indexed by the ticker symbol. It contains price, volume, high/low/change, timestamp, etc., For our purposes, the price, volume and timestamp are essentially all we need.

SQL to create the table:

 CREATE  TABLE  `stocks`.`quotes` (  `ticker` varchar( 12  )  NOT  NULL ,
 `price` decimal( 10, 2  )  NOT  NULL ,
 `qtime` datetime NOT  NULL ,
 `pchange` decimal( 10, 2  )  NOT  NULL ,
 `popen` decimal( 10, 2  )  NOT  NULL ,
 `phigh` decimal( 10, 2  )  NOT  NULL ,
 `plow` decimal( 10, 2  )  NOT  NULL ,
 `volume` int( 11  )  NOT  NULL ,
 `ttime` timestamp NOT  NULL  DEFAULT CURRENT_TIMESTAMP ,
 `id` int( 11  )  NOT  NULL  AUTO_INCREMENT ,
 `spare` varchar( 30  )  DEFAULT NULL ,
 UNIQUE  KEY  `id` (  `id`  ) ,
 KEY  `ticker` (  `ticker`  )  ) ENGINE  =  MyISAM  DEFAULT CHARSET  = latin1 COMMENT  =  'stock quote transactions';

creating the database, user, and table

  • Log into  phpmyadmin as root
  • Create a new database called ‘stocks’
  • In privileges, add a user called: ‘webdb1′ with a password of ’34door’ (note you can change the password later)
  • In SQL, copy in the above query to create the ‘stocks’ table

Instructions

Web client

The webpage control program allows you to select stocks by ticker symbol, and get either one quote or get quotes at regular time interval. Each quote is inserted into the stock table for later retrieval and analysis.

 

The web front end is quirky so I will describe it in terms of how you might typically use it:

market is open – and you just want to play music based on current stock prices
  1. Enter the ticker symbols for your stocks
  2. Press ‘tracking’ button – so the quotes get saved
  3. Enter the IP address of the computer running Max
  4. Press the ‘auto’ button in the upper left corner – it will run and play forever
market is closed – or you want to play historical data you have saved
  1. Enter the ticker symbols for your stocks
  2. Enter the IP address of the computer running Max
  3. set start end end dates
  4. Press the ‘play’ button to play once or press ‘loop’ to play continuously (using time interval in seconds)
  5. market is open – you just want to collect stock quote data
  6. Enter the ticker symbols for your stocks
  7. Press the tracking button so quotes will get saved
  8. Press the ‘get quotes’ button to get current quote or press ‘loop’ button (on the same line) to retrieve quotes  continuously every 30 seconds.

Instructions

Max patch

  1. Make sure the IP address is set to the address of your server
  2. Select the Midi port for output
  3. Play a few test notes
  4. Select either ‘one instrument’ mode (piano) or multi instrument mode. Each time you click the multi instrument button it randomly selects a new combination 

notes on stock market data

To look at historical trends, you would need access to historical stock data. To use it as a tool for short term analysis, you would need access to real-time quote data in an API. At the time, both of these cost money.

However, it doesn’t cost money to get recent quotes from Yahoo throughout the day and store them in a database – so that’s the approach I took.

If I were to do this project today, I’d look for a free online source of historical data, in machine-readable form – because the historical data provides the most interesting and organic sounds when converted into music. The instant high speeding trading data would probably make interesting sounds as well, but you still need to pay for the data.

notes on local files

basic Arduino connections to Max

  • Dim an LED from Max.
  • Read the value of a potentiometer in Max.

download

https://github.com/tkzic/max-projects

folder: arduino-basics

patches:

  • arduino-dimmer.maxpat
  • arduino-serial-read.maxpat

Arduino dimmer

dim an LED from Max

From the Arduino playground

http://playground.arduino.cc//Code/MaxCommunicationExamples

circuit

Connect an LED to pin 9 and ground. The shorter lead goes to ground.

sketch

Load the Arduino example sketch: communications | dimmer

Max
  1. open arduino-dimmer.maxat
  2. Click the “print” message to print the list of ports to the Max window. Then set the port in the serial object, using the port message. For example: “port c”.
  3. Move the slider to dim the LED

Arduino serial read

Read the value of a potentiometer

This patch is a bit more involved. Refer to the Max Communications Tutorial 2: Serial Communication. In fact, much of this code was lifted from the tutorial.

circuit
  • Connect an LED to pin 9 and ground. The shorter lead goes to ground.
  • Connect a potentiometer (center lead) to Analog pin 0. The side leads connect to +5v and ground.
sketch

Load the Arduino example sketch: Analog | analogInOutSerial

Max
  1. Open arduino-serial-read.maxpat
  2. Click the “print” message to print the list of ports to the Max window. Then set the port in the serial object, using the port message. For example: “port c”.
  3. Activate toggle to start polling serial port
  4. Activate toggle number 3 to view formatted output in the Max window
  5. Turn the potentiometer to send data to Max

general suggestions:

  • Try not to get discouraged.
  • If weird things happen, close Max, reconnect Arduino, the re-open Max