Download Java Virtual Machine

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Class (computer programming) wikipedia , lookup

Name mangling wikipedia , lookup

Java syntax wikipedia , lookup

Structured programming wikipedia , lookup

C Sharp syntax wikipedia , lookup

Scala (programming language) wikipedia , lookup

Object-oriented programming wikipedia , lookup

Go (programming language) wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Java (programming language) wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Java performance wikipedia , lookup

Transcript
Virtual
Drum-set
Developer:
Hargovind Singh
IT-2 (5th sem)
G.T.B.I.T.
Music heard so deeply
That it is not heard at all, but you are
the music
While the music lasts.
T. S. ELIOT, "The Dry Salvages" (5), Four
Quartets, 1943
Part I
INTRODUCTION
Project Intro.
Virtual Drum-set : a virtual machine capable of
playing drum patterns according to our choice; a
programmed percussions playable at an independent
platform.
It is intended for musicians as well as layman to
compose various musical pieces according to their
propelling ideas. This piece of work of mine will cut
down time that many people dissipate and assist
them to add wings to their creativity.
It uses an easy and understandable interface to
compose a maximum 16-beat pattern. The values
can be assigned by the user as needed and
previewed. It can also be adored by selecting the
tempo.
This elegant version of drum set is designed using
Java Programming Language.
What I did …
First I mapped the real entity, the drum-set, with its
own property & behavior, then using programming
skills I framed a GUI (Graphical User Interface)
using the classes provided in javax.swing package.
As the main focus was on inculcating the drum
behavior for my GUI, I also used the classes
provided in javax.sound.midi package.
Pic…1
Part II
WHAT IS DRUMSET ?
Terms related to Drums …
Drum : A percussion instrument with a skin stretched
across a frame, sounded by being struck with sticks or
hand.
Drumbeat : A stroke or pattern of strokes on a drum.
Drum kit : A set of drums, cymbals, and other
percussion instruments.
Drum roll : A rapid succession of drumbeats.
Drumstick : A stick used for
beating a drum.
Drummer : A person who plays a drum or drums.
Part III
WHAT IS JAVA ?
Java’s Intro.
Java Technology is both a programming language and a
platform. Java is originally developed by James Gosling at Sun
Microsystems (which is now a subsidiary of Oracle
Corporation) and released in 1995 as a core component of Sun
Microsystems' Java platform.
Java applications are typically compiled to bytecode (.class file)
that can run on any Java Virtual Machine (JVM) regardless of
computer architecture.
It is intended to let application developers "write once, run
anywhere"
Java is currently one of the most popular programming
languages in use, and is widely used from application software
to web applications.
HISTORY:
James Gosling, Mike Sheridan, and Patrick Naughton initiated
the Java language project in June 1991. Java was originally
designed for interactive television, but it was too advanced. The
language was initially called Oak after an oak tree that stood
outside Gosling's office; it went by the name Green later, and
was later renamed Java, from a list of random words.
Sun Microsystems released the first public implementation as
Java 1.0 in 1995.
Versions Released…
Java = 1.0, 1.02, 1.1
Java2 = 1.2 , 1.3, 1.4
Java 5.0 = 1.5 (code name = ‘Tiger’)
The Java Programming Language is a high level
language that can be characterized by following
buzzwords:
* Simple
* Object Oriented
* Secure
* Robust
* Distributive
*Dynamic
* Multithreaded * Architecture neutral
* Portable
How does a Java program gets executed …
The Java Programming
Language
In the Java programming Language, all source code is written in
plain text files ending with the .java extension. These source files
are compiled into .class files by the javac compiler. A .class file
does not contain code that is native to your processor; it instead
contains bytecodes, the machine language of the Java Virtual
Machine (JVM). The java launcher tool then runs your
application with an instance of the Java Virtual Machine.
The Java Platform
A
Platform
is the hardware or software environment in
which a program runs. The most popular platforms are
Microsoft Windows, Linux, Solaris OS & Mac OS. The Java
platform differs from most other platforms in that it’s
software-only platform that runs on top of other hardwarebased platforms.
The Java platform has two categories :
* The Java Virtual Machine
* The Java Application Programming Interface (API)
Part IV
WHAT IS GUI ?
Graphical User Interface
(GUI) offers a profoundly
environment than the step-by-step, linear world of procedural
programs. The GUI presents many features all appearing to
operate independently and in parallel, even though usually run
with a single processor. GUIs match well with the modularity
of object oriented languages since many different parts of a GUI
can be created as class objects.
In the procedural world, the user simply starts a program &
waits for it to churn through its algorithm and eventually stop.
In the GUI environment, the program instead waits for the user
to select some task and then it carries out that selected action.
(Meanwhile, the processor, which could be physical or a Virtual
Machine, will switch frequently to other tasks.)
How a GUI is implemented in Java …
>> AWT (Abstract window Toolkit)
>> Applet
>> Swing
What I used …
>> Swing
The
Swing
classes build upon lower
level classes of the original AWT (java.awt)
graphics packages. The Swing user
interface components, which always begin
with “J”, extend from the container and
Component classes.
The JComponent subclasses are
lightweight, so they essentially run within
a single heavyweight high level
component, such as JFrame and JDialog, and
draw and re-draw themselves within Java,
no native code peer components involved.
Combined with the event handling
process, swing components provide a very
flexible and elaborate GUI tools.
Snapshots of running GUI …
A musician may suddenly reach a point at which pleasure in the
technique of the art entirely falls away, and in some moment of
inspiration, he becomes the instrument through which music is played.
EDWIN DILLER STARBUCK, The Psychology of Religion: An Empirical
Study of the Growth of Religious Consciousness, 1899
Part V
DEPTH OF GUI
How Drum is implemented in the GUI…
Java doesn’t provide drum beats with that ease as it seems playing it.
We have to construct several OOP modules consisting usage and
implementation of several API’s interfaces , classes etc. that can load,
play, speed/halt down the data in MIDI format.
The
Java Sound API
includes support for both digital
audio and MIDI data. These two major modules of functionality are
provided in separate packages:
* javax.sound.sampled
This package specifies interfaces for capture, mixing, and playback of
digital (sampled) audio.
* javax.sound.midi
( This One is used in project)
This package provides interfaces for MIDI synthesis, sequencing, and
event transport.
What is MIDI ? ...
Musical Instrument Digital Interface (MIDI)
The javax.sound.midi package contains APIs for transporting and
sequencing MIDI events, and for synthesizing sound from those
events.
Sampled audio is a direct representation of a sound itself, MIDI
data can be thought of as a recipe for creating a sound, especially
a musical sound. MIDI data, unlike audio data, does not describe
sound directly. Instead, it describes events that affect the sound a
synthesizer is making.
MIDI data is analogous to a graphical user interface's keyboard
and mouse events. In the case of MIDI, the events can be
thought of as actions upon a musical keyboard, along with
actions on various pedals, sliders, switches, and knobs on that
musical instrument.
These events need not actually originate with a hardware
musical instrument; they can be simulated in software, and
they can be stored in MIDI files.
Programs that help in making of a MIDI sound
A program that can create, edit, and perform these files is called
a sequencer. Or a s/w or h/w device that plays back a MIDI
sequence is known as sequencer. A sequence is a data structure
containing musical information (often an entire song
/composition) that can be played by a sequencer object.
The synthesizers interpret the MIDI events that they receive
and produce audio output. MIDI synthesizers are also capable
of generating various kinds of sound effects. A MIDI sequence
contains lists of time-stamped MIDI data, such as might be
read from a standard MIDI file. Most sequencers also provide
functions for creating and editing sequences.
A MIDI track is an independent stream of MIDI events (timestamped MIDI data) that can be stored along with other tracks in
a standard MIDI file. The MIDI specification allows only 16
channels of MIDI data, but tracks are a way to get around this
limitation.
How does the instrument play …
Sequencers play >> Sequences
Sequences contain >> Tracks
Tracks contain >> MIDI Events
MIDI Event is a message that a sequencer can understand. A
MIDI event include “ Notes to play, for how long, changing
the instrument, etc. ”
Integrating it …
1. We’ll take access to installed MIDI system resources such as
synthesizers, sequencers and MIDI i/p & o/p ports.(Through
MIDI System).
2. Create a sequence, pass the track made to it (containing
MIDI events).
3. Connect this sequence (through transmitter instance) to the
installed sequencer, which looks up for the MIDI events from
its personal soundbank (or by default get connected to default
reciever).
4. Start the sequencer, it starts playing the sequence.
5. Choose to listen to it, increase/decrease tempo or send it to
some network or over a file system.
6. Enjoy.
The music in my heart I bore,
Long after it was heard no more.
WILLIAM WORDSWORTH, closing lines, "The Solitary Reaper," 1807