My List

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, September 19, 2007

Notes of jMusic (1) - Basic Structure

jMusic is a programming library written for musicians in the Java programming language. jMusic is designed to be used as a compositional medium, therefore it is primarily designed for musicians - not computer programmers. However, many people find jMusic a useful API for music software development, in particular for digital instrument making.

Score (Contains any number of Parts)
|
+---- Part (Contains any number of Phrases)
|
+---- Phrase (Contains any number of Notes.)
|
+---- Note (Holds information about a single musical event.)

Notes (jm.music.data.Note)
Contain information:

1. Pitch - the note's pitch
2. Dynamic - the loudness of the note
3. RhythmValue - the length of the note (e.g., Crotchet)
4. Pan - the notes position in the stereo (or more) spectrum.
5. Duration - the length of the note in milliseconds
6. Offset - an deviation from the 'normal' start time of the note

Notes with a pitch of the minimum integer are rests, those between 0 <> 127 are exactly the same as normal sounding notes numbered like the MIDI specification. Notes with a pitch specified as a double value, e.g., 440.0, are frequency values for the note pitch. In general, note pitch refers to the chromatic key number (as per MIDI) as an int and the note frequency refer to the value in hertz as a double value.

Phrases
Every Phrase objects contains a list of notes. The list that does all these things is java.util.Vector.

Parts
Part is a class that surprisingly enough holds the notes (in phrases) to be played by an instrument. A part contains a vector that contains lots of phrases (sound familiar). A part also has a title ("Violin 1" for example), a channel, and an instrument.

Scores
The Score class is used to hold score data. Score data includes is primarily made up of a vector of Part objects. Commonly score data is algorithmically generated or read from a standard MIDI file, but can also be read and saved to file using Java's object serialization. In this way a Score's data can be saved in a more native context. To find out how to read from and write to standard MIDI files or to use object serializationcheck out the jm.util.Read and jm.util.Write classes.

// give this class access to the jMusic classes
import jm.JMC;
import jm.music.data.*;
import jm.util.*;

/**
* This is the simplest jMusic program of all.
* The eqivalent to a programming language's 'Hello World'
*/

public final class HelloWorld implements JMC {
public static void main(String[] args){

//create a middle C minim (half note)
Note n = new Note(C4, MINIM);

//create a phrase
Phrase phr = new Phrase();

//put the note inside the phrase
phr.addNote(n);

//pack the phrase into a part
Part p = new Part();
p.addPhrase(phr);

//pack the part into a score titled 'Bing'
Score s = new Score("HelloWorld");
s.addPart(p);

//write the score as a MIDI file to disk
Write.midi(s, "HelloWorld.mid");
}
}


Sunday, March 18, 2007

比較innerText; outerText; innerHTML; outerHTML

TEST relief.twbbs.org


innerText: 設置或獲取位於對像起始和結束標籤內的文本
--> TEST relief.twbbs.org

outerText: 設置或獲取對象的文本
--> TEST relief.twbbs.org

innerHTML: 設置或獲取位於對像起始和結束標籤內的 HTML
--> TEST relief.twbbs.org

outerHTML: 設置或獲取對象及其內容的 HTML 形式
--> TEST relief.twbbs.org
Demo: http://relief.twbbs.org/code/html/


[ActionScript] 動態文字遮罩

myMovieClip .setMask ( maskMovieClip )

myMovieClip : The instance name of a movie clip to be masked.
maskMovieClip : The instance name of a movie clip to be a mask.

The setMask method allows multiple-frame movie clips with complex, multilayered content to act as masks. You can shut masks on and off at runtime. However, you can't use the same mask for multiple maskees (which is possible by using mask layers). If you have device fonts in a masked movie clip, they are drawn but not masked. You can't set a movie clip to be its own mask, for example mc.setMask(mc) .

From: http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary566.html