Melodica App for iPhone

I’ve just come across this really lovely tone-matrix like soundtoy app for the iPhone. Its called Melodica, and like the Tone matrix, is based on the D Pentatonic scale: e f# a b d e f# a b d. Because of this, it’s easy to make it sound nice. I think the iPhone tool will also be a real help to me, in explaining to house and course mates what I am building. It’s an addicting and infectious little app – just the aspects I’d like to get across in my project too.

Check out a video demo of the app in use at:

http://www.youtube.com/watch?v=JWbtmxC0Lkk

Posted in Final Year Project | Comments Off

LED and batteries

My LED’s have arrived… 300 of them. 256 (4 per square) plus 44 spare in case any blow or are broken.

Look at this pile:

Here is a demo of one in use:

The batteries have also arrived. A 3V battery for all 4 LED’s of a square. Here they are:

The battery will be wired to a foil square on the wooden base, another foil square will be attached to the papered plastic, and both foils would be wired to the LED’s.

Posted in Final Year Project | Comments Off

Project Evaluation

My Project was intended to use BBC RSS data to create a video newsreel. The idea of auto editing should be a form of citizen journalism.

The project used Yahoo Pipes, a tool which interacts and edits RSS feeds. Through a number of Yahoo pipe trials, I was able to create a pipe which searched the BBC headlines in YouTube, resulting in an RSS feed of YouTube links.

These links, and the headlines that go with them, are transferred to a Flash frame, designed to replicate a BBC news frame. Within Flash, the headlines are displayed.

I am dissappointed that currently the YouTube video displayed is not the one linked (and related to) the RSS headline. This was due to a lack of time, from a combination of personal (minor) illness, and a major family crisis (father in law became seriously ill while in Chile, ruling out most of my Easter holiday. This is increedibly dissappointing, since I learnt so much through the project. I would only need a few extra hours to complete, and now have a much fuller understanding.

Since I am so close to the desired outcome, I will continue to work on the project.

Once expanded to display the resultant youtube videos, there are a few other additions I could make. Searching citizen video journalism sites, such as LiveLeak, would allow me to have more political and controversial footage  – YouTube is presented as a light-hearted video sharing site, and LiveLeak videos are grittier. A combination of video sources would really add to the project.

Another possible expansion would be to use a combination of news sources. Aspects such as the “trending” topics on twitter would definately add a more public, citizen edge to the project. Adding text and comments from members of the public would be interesting. Possibly I could search for individual soundbites (such as audioboo.com) for voiceover commentary on the newsstories.

I feel like my project fulfills the brief well, as it definately adds meaning to the data. Going with the adage “A picture paintas a thousand words,” I feel video can add even more meaning. In the wake of the Web 2.0 phenomenon, websites and apps are encouraging participation, crowd sourcing, etc. This is one of the aspects of the web that interests me most, so I’m pleased tohave createda project that sits within this area. It uses a variety of sources, and has an unpredictabilty that is interesting, unique, and satisfying.

Posted in 4D | Comments Off

Drumbot

Drumbot

Drumbot are a series of music related web apps.  Included are a simple guitar tuner that helps you tune your axe by ear, a set of drum loops that you can queue up and save (for “those who can’t find a real drummer to jam with”), a metronome, a drum pattern sequencer to create your own drum loops, and tap BPM, an app that tells you how many beats permit you’re hitting your keyboard at.

Posted in Final Year Project | Comments Off

Error *almost* overcome – trace output

I’ve managed to fix the error, by calling a function inside my video actionscript, when the timer event ticks.

The code for this is called in response to the timer event: youtubevideo.HeadlineChange ();

This function within my video movieclip, youtubevideo, means I can then trace the value of t, my counter, to see where in the list of youtube vids I should be.
function HeadlineChange () {
trace (“From video, my counter, t = ” + MovieClip(root).t);
}

Here is the resulting trace:

CurrentHeadline:VIDEO: William drives bride in Aston Martin
player ready:
player state: -1
SecondsPassed() called @ 10458 ms
My counter, t =1
CurrentHeadline:VIDEO: First kiss as husband and wife
From video, my counter, t = 1
SecondsPassed() called @ 20461 ms
My counter, t =2
CurrentHeadline:VIDEO: First glimpse of the evening dress
From video, my counter, t = 2
SecondsPassed() called @ 30467 ms
My counter, t =3
CurrentHeadline:VIDEO: Ceremony watched around the world
From video, my counter, t = 3
SecondsPassed() called @ 40469 ms
My counter, t =4
CurrentHeadline:VIDEO: New Yorkers party under Brooklyn bridge
From video, my counter, t = 4

As you can see from the trace output above, both my video and my main root timeline agree with where I am in the headline list. The counter values traced are the same. Now I just need to use that number to display the corresponding vid link.

Posted in 4D | Comments Off

Oh no, ERROR

On the final hurdle, I’m getting errors. I can’t access the headline from inside the video code… so I can’t change the video as my headline changes. Aaargh!

/*———————Error Messages———————
1120: Access of undefined property t.
1120: Access of undefined property CurrentHeadline.

Posted in 4D | Comments Off

Trace Results

Loaded Feed

This is the result of the trace to see if my Yahoo Pipe RSS has loaded correctly.
http://www.youtube.com/watch?v=p_Nrk2uy87E

http://www.youtube.com/show?p=ioqt1IdznWs&s=3

http://www.youtube.com/show/globaltreasures

http://www.youtube.com/news

http://www.youtube.com/watch?v=LoHbJwEi24k

http://www.youtube.com/user/IranContraScumDid911

http://www.youtube.com/watch?v=ourclBYzuS0

http://www.youtube.com/user/KamikazeKoscki

http://www.youtube.com/movies

http://www.youtube.com/watch?v=-V1QLUREY9k

http://www.youtube.com/user/ntvuganda

http://www.youtube.com/watch?v=qlf_GAf_l5A

http://www.youtube.com/watch?v=jfvFayHczCg

http://www.youtube.com/all_comments?v=FYz7AHtKfEE

http://www.youtube.com/watch?v=oRXlBeIfn3g

http://www.youtube.com/user/Leave99Productions

http://www.youtube.com/watch?v=upDSu-xqDCA

http://www.youtube.com/user/healthyinformation

http://www.youtube.com/user/LennarOnline

http://www.youtube.com/user/nyevita

http://www.youtube.com/watch?v=feinD1ySaNg

http://www.youtube.com/user/itnnews

http://www.youtube.com/user/sttabear

http://www.youtube.com/user/acidfrog

This is the list of youtube videos for the current top news headlines, as defined by my Yahoo pip

player ready:
player state: -1

CurrentHeadline:VIDEO: William drives bride in Aston Martin
SecondsPassed() called @ 10147 ms
y=1
CurrentHeadline:VIDEO: First kiss as husband and wife
SecondsPassed() called @ 20151 ms
y=2
CurrentHeadline:VIDEO: First glimpse of the evening dress
SecondsPassed() called @ 30156 ms
y=3
CurrentHeadline:VIDEO: Ceremony watched around the world

SecondsPassed() called @ 40159 ms
y=4

The above traces show the content of the Headline array, the current headline. This is shuffled on the timer, y shows how many times the timer event has been called. The headlines change every 10 seconds (or 10000 ms), so this trace shows 40 seconds of progression through the headlines.

Posted in 4D | Comments Off

Video Code

This is the final piece of actionscript, and the one I struggled the most on. It will take some explaining… but here goes!


Security.allowDomain(“www.youtube.com”,”http://s.ytimg.com”, “http://pipes.yahoo.com”);

I have already blogged about my security sandbox issues. This line of code was the fix. I had to add youtube, youtube’s favicon, and yahoo’s pipes site to a list of allowed domains. Flash is happy to communicate with online sites, only if you allow them using this Security.allowDomain code.

import flash.xml.*;
This import allows flash to communicate with the XML contained in the RSS feed generated by my Yahoo Pipe from BBC and YouTube. The feed lists YouTube links relating to the BBC top stories.
//variables and objects
var feed:String = “http://pipes.yahoo.com/pipes/pipe.run?_id=b586d73664d960245555fb6153c36275&_render=rss”;
var linkloader:URLLoader = new URLLoader();
var xml_data:XML;

This sets up my feed to interact with Flash, allowing it to be loaded with the URLLoader, and handled as xml data.

//var videos:Array;

This is an empty array, created to hold the videos I wish to display.
/*News Feed Loading*/
//listeners

linkloader.addEventListener(Event.COMPLETE, loadXML);
linkloader.load(new URLRequest(feed));

//functions

function loadXML(e:Event):void{
//copies loaded XML into XML Data
trace(“Loaded Feed”);
xml_data = new XML(e.target.data);
//trace(xml_data);

This copies my Yahoo Pipe RSS data, into the xml_data array.

var item_list:XMLList = xml_data.channel.item.link;
for (var x = 0; x < item_list.length(); x++){
trace(item_list[x]);
//videos[(x)] = item_list[x];
}

}

For each RSS item in the list, the YouTube link is extracted

// This will hold the API player instance once it is initialized.

var player:Object;

var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);

loader.load(new URLRequest(“http://www.youtube.com/v/g9f-6jygRJk?version=3″));

The video loader is set up, at the moment to explicitly display one video. It doesn’t yet use the URL’s held in my above link list.

function onLoaderInit(event:Event):void {

addChild(loader);

loader.content.addEventListener(“onReady”, onPlayerReady);

loader.content.addEventListener(“onError”, onPlayerError);

loader.content.addEventListener(“onStateChange”, onPlayerStateChange);

loader.content.addEventListener(“onPlaybackQualityChange”,onVideoPlaybackQualityChange);

}

The video player is loaded, and is set to respond to a variety of errors with error description functions. These functions are explained individually below.

function onPlayerReady(event:Event):void {

// Event.data contains the event parameter, which is the Player API ID

trace(“player ready:”, Object(event).data);
If the player sets up correctly, this trace is sent.
// Once this event has been dispatched by the player, we can use
// cueVideoById, loadVideoById, cueVideoByUrl and loadVideoByUrl
// to load a particular YouTube video.

These comments explain that the player needs to be ready before it can load a video.

player = loader.content;

// Set appropriate player dimensions for your application

player.setSize(580, 360);

}



Once the player is ready, the content can be loaded, at the appropriate size.

function onPlayerError(event:Event):void {

// Event.data contains the event parameter, which is the error code

trace(“player error:”, Object(event).data);

}

This trace lists any errors which may have occured, and the object that generated them. This was helpful in the debugging process, as it allowed me to respond to each error individually, and also created a “get out” when trapped in an error loop.

function onPlayerStateChange(event:Event):void {

// Event.data contains the event parameter, which is the new player state

trace(“player state:”, Object(event).data);

}

The player always begins paused, clicking on it causes it to play. The state change between loading, playing, paused, and finished is recorded in numbers 0-3. When changing from each state, the trace is called.

function onVideoPlaybackQualityChange(event:Event):void {

// Event.data contains the event parameter, which is the new video quality

trace(“video quality:”, Object(event).data);

}

The video quality is controlled by YouTube, and accessed using their player. Changing the video quality mid-play doesn’t count as a statechange, but nonetheless did affect the playback achieved by my project. So this trace was introduced, allowing me to see if any errors were as a result of  a change in video quality.

Posted in 4D | Comments Off

Time Code

Here is the code I have used to display the system time in my Flash Document. I feel this adds to the authenticity of thew project, most news programs show the time. Using the system timer ensures it is accurate to whichever local timezone. The code is fairly simple:

//imports

import flash.system.*;
import flash.text.*;
import flash.utils.*;

These imports allow flash to access the system time, create a text box. and use the utils library to display the time in the text box.

//variables and objects
var autoDelay:Timer = new Timer(1000);

This timer creates a delay of 1000 ms, 1 second, between calling the time.
//Intialise and Draw the Text Field
var timeDisplay:TextField = new TextField();

timeDisplay.width = 100;
timeDisplay.x = 390;
timeDisplay.y = 290;

timeDisplay.textColor = 0xFFFFFF;
var timefontSize:String = “35″;
var timefont:String =”Helvetica”;

addChild(timeDisplay);

All this is just to add the text box “timeDisplay” to the stage, with appropriate font, colour and size properties.

//listeners

autoDelay.addEventListener(TimerEvent.TIMER, timeDisplayTime);
autoDelay.start();


This listener responds to the timer, calling the timeDisplayTime function (explained below) after each timer tick. It then starts the timer.

//functions

function makeDoubleDigit(input:String):String{
var output:String;
if (input.length == 1){
output = “0″ + input;
} else {
output = input;
}

return output;
}

This is a fairly self explanatory function, which adds a preceeding value if the hours, minutes, or seconds from the system clock are a single digit. For example, 5 past 9 in the morning could come in as 9:5:0 and would need to be converted to 09:05:00. This keeps my clock consistent with regular digital clocks, always being 6 digits long.

function timeDisplayTime(event:TimerEvent):void{
//get current time
var output:String;

var currentTime:Date = new Date();
var Seconds:int = currentTime.getSeconds();
var Minutes:String = makeDoubleDigit(String(currentTime.getMinutes()));
var Hours:String = makeDoubleDigit(String(currentTime.getHours()));

The above code gets the system time, and splits it into hours, minutes and seconds, calling the makeDoubleDigit function on each as it does so.

//timeDisplay with colon if seconds even, without colon if odd
if ((Seconds & 1) == 0){
output = “<font face=\”" + timefont + “\” size=\”" + timefontSize + “\”>”+ Hours + “:” + Minutes + “</font>”;
} else {
output = “<font face=\”" + timefont + “\” size=\”" + timefontSize + “\”>”+ Hours + ” ” + Minutes + “</font>”;
}

This is a bit of a cheat method for making the colon between each hours:minutes:seconds flash. I’m not sure WHY exactly it does so, but on all the digital clocks in the house, and on BBC News 24, their colons flash. So mine does too. The string that displays the time uses an if statement to display the colon only if an even number of seconds. It’s strange, but it works…

timeDisplay.htmlText = output;

}

Posted in 4D | Comments Off

News Scroller Code

Here is the actionscript I am using:

import flash.xml.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import caurina.transitions.Tweener;

The above series of imports allows Flash to read XML, from the web, read in the system time from the local machine, display text, and scroll the news text as a marquee, using caurina tweener.

//variables and objects
var feed:String = “http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml”;
var opening:String = “BBC News:”;
var item_gap:String = “         “;
var loader:URLLoader = new URLLoader();
var xml_data:XML;
var Headlines:Array = new Array();
var Displayed_Headlines:int = 0;

This list of variables load the URL of the XML RSS BBC feed (what a lot of acronyms!!!) It then adds an opening “BBC News:” and an item gap to stop subsequent headlines overlapping. The array of headlines is added to a text field, displayed headlines is a counter to check how far we are through the headline list.
//Intialise and Draw the Text Field
var Display:TextField = new TextField();

Display.width = 6000;
Display.x = 330;
Display.y = 333;

Display.textColor = 0xFFFFFF;
var fontSize:String = “40″;
var font:String =”Helvetica”;

addChild(Display);

This is all just to add a text field to show the headline.


/*News Feed Loading*/

//listeners

loader.addEventListener(Event.COMPLETE, loadXML);
loader.load(new URLRequest(feed));

//functions

function loadXML(e:Event):void{
//copies loaded XML into XML Data
//trace(“Loaded Feed”);
xml_data = new XML(e.target.data);
//trace(xml_data);

If my newsfeed loads correctly, I can trace the words “Loaded feed” and then the xml_data that the feed loaded into. These are commented out as I’m confident that the feed loads correctly. However, they were very useful in my debugging.

var item_list:XMLList = xml_data.channel.item.title;

for (var x = 0; x < item_list.length(); x++){
//trace(item_list[x]);
Headlines[(x)] = item_list[x];
}


This copies the XML into my headlines array. This means I can see how many headlines I have (the RSS is constantly updating, so this headlines array gives me a limited number to work with).

DisplayNextHeadline();
calls a function explained below.
var myTimer:Timer = new Timer(10000); // 10 seconds
myTimer.addEventListener(TimerEvent.TIMER, SecondsPassed);
myTimer.start();

This timer counts every ten seconds, calling a function called SecondsPassed (explained below). The timer allows a gap between each headline, to show the corresponding video.

var y = 0;

function SecondsPassed(event:TimerEvent):void {
trace(“SecondsPassed() called @ ” + getTimer() + ” ms”);
y++;
trace (“y=” +y);
Headlines[0] = item_list[y];
DisplayNextHeadline ();
}

}

y is a simple counter to help in my debugging process. It allows me to see the increments being made by my timer (how many times SecondsPassed has been called). The trace gives me the ms at which Seconds Passed was called. This is howe much time has passed since my timer began.

Y is increased each time SecondsPassed is called (every 10 seconds, y increases by 1). Then my headline array is set to y’s position, and DisplayHeadine method (explained below) is called.
function DisplayNextHeadline ():void{
Display.htmlText = “<font face=\”" + font + “\” size=\”" + fontSize + “\”>” + opening + item_gap + Headlines[0] + “</font>”;
AnimateDisplay();
}

This is the formation of the HTML text shown in the Display box. It shows the headline in position y of my item list array. This means it scrolls through the headlines every ten seconds. The AnimateDisplay function is the final one, explained below:
function AnimateDisplay():void{
//Animation
if (Tweener.isTweening(Display) == false){
Displayed_Headlines = 0;
}
if(Displayed_Headlines != 12){
Displayed_Headlines ++;
Display.x = 330;
Display.y = 333;
Tweener.addTween(Display, {x:-Display.width, y:Display.y, time:45, transition:”linear” , onComplete:AnimateDisplay});
}
else{
Tweener.removeTweens(Display);

//reload feed
loader.load(new URLRequest(feed));
}

}

Animate display uses the Caurina tweener to scroll the current headline across the screen. It also resets the DisplayedHeadline value if it gets beyond 12.

The code for the video is contained separately, as is the code for the system timer.

Posted in 4D | Comments Off