Professional Documents
Culture Documents
on
Groove Studio
1
ACKNOWLEDGEMENT
It gives us immense pleasure to take this opportunity to acknowledge our obligation to our
project guide Mr. Prashant Gupta of Northern India Engineering College, who not only was kind
enough to permit us undertake the project work (which is essential for partial fulfillment of our
Bachelor of Technology(Information Technology) Degree, but also took great effort in making
the project a success. We thank to our guide, as it would have been a tough job for us to
complete this project without his keen interest, moral support, suggestion and valuable guidance
in completion of the project.
We would also like to thank to Mr. Rajesh Yadav (H.O.D. of I.T. department) , for his timely
help and guidance.
We would also like to thank to IT Department teachers of Northern India Engineering College.
We sincerely thank to all the people who have been directly or indirectly involved in making the
project a great success.
Anand Marwaha(0621563107)
Apurv Mehta(0651563107)
Aditya Bharti(0761563107)
2
Index
1 Introduction 4
2 Use Case Diagram 5
3 Software Development Approach 7
4 Design Descriptions 9
5 Implementation 10
6 Testing Strategies 24
7 Screenshots 27
8 Conclusion 28
9 References 28
Introduction
3
Groove Studio is a Java application in which users use a 16x16 Grid of checkboxes to create a
beat with various percussion instruments. Beats can be saved and loaded easily. The entire
application is as intuitive and user-friendly as possible. BeatBox is primitive devices that plays
rigid patterns of notes using a grid of 16 buttons, or steps, each step being 1/16th of a measure.
These patterns of notes are then chained together to form longer compositions.
1.1 Function
This document will present a detailed description of a Musical Jukebox “Groove Studio”. It will
explain the purpose and features of the system, the constraints it must operate under. This
document is intended for developers and stakeholders of the system.
1.2 Scope
This software will be a Musical Jukebox to allow entertaining self created music for the users.
Using this application user can include various instruments and create a self composed musical
piece. In addition to the above feature the user can chat with other users on the chat server and
share tunes with them using the chat module. Features like tempo change and saving files to the
hard disk will be provided
4
Chat
Start/Stop
User
Tempo Up/Down
Groove Studio has one actor which is the user running the application he can interact with four
use cases. The user can chat with other users who are online on the server. He can create musical
files and can save and load these files on the hard disk. Users can start and stop the playing of the
sound and lastly he can change the tempo of the music.
5
Initial Step-By-Step Description
Saving
Loading
6
3.2 Incremental Model
The incremental model is an intuitive approach to the waterfall model. Multiple development
cycles take place here, making the life cycle a “multi-waterfall” cycle. Cycles are divided up
into smaller, more easily managed iterations. Each iteration passes through the requirements,
design, implementation and testing phases. A working version of software is produced during the
first iteration, so you have working software early on during the software life cycle. Subsequent
iterations build on the initial software produced during the first iteration.
Requirement Analysis & Definition: All possible requirements of the system to be developed
are captured in this phase. Requirements are set of functionalities and constraints that the end-
user (who will be using the system) expects from the system. The requirements are gathered
from the end-user by consultation, these requirements are analyzed for their validity and the
possibility of incorporating the requirements in the system to be development is also studied.
Finally, a Requirement Specification document is created which serves the purpose of guideline
for the next phase of the model.
7
System & Software Design: Before a starting for actual coding, it is highly important to
understand what we are going to create and what it should look like? The requirement
specifications from first phase are studied in this phase and system design is prepared. System
Design helps in specifying hardware and system requirements and also helps in defining overall
system architecture. The system design specifications serve as input for the next phase of the
model.
Unit Testing: On receiving system design documents, the work is divided in modules/units and
actual coding is started. The system is first developed in small programs called units, which are
integrated in the next phase. Each unit is developed and tested for its functionality; this is
referred to as Unit Testing. Unit testing mainly verifies if the modules/units meet their
specifications.
System Testing: As specified above, the system is first divided in units which are developed and
tested for their functionalities. These units are integrated into a complete system during
Integration phase and tested to check if all modules/units coordinate between each other and the
system as a whole behaves as per the specifications. After successfully testing the software, it is
delivered to the customer.
Operations & Maintenance: This phase of is virtually never ending phase (Very long).
Generally, problems with the system developed (which are not found during the development life
cycle) come up after its practical use starts, so the issues related to the system are solved after
deployment of the system. Not all the problems come in picture directly but they arise time to
time and needs to be solved; hence this process is referred as Maintenance.
Design Descriptions
8
4.1Context Diagram (0 Level DFD)
Load file on
Hard disk
9
Implementation
5.1 Coding
File name: BeatBox.java
import java.awt.*;
import javax.swing.*;
import javax.sound.midi.*;
import java.util.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import javax.swing.event.*;
class BeatBox
{
JPanel background,mainPanel,panel;
ArrayList<JCheckBox> checkboxList;
JFrame theFrame;
JList incomingList;
JTextField userMessage,t;
JLabel temp;
//int nextNum=1;
Vector<String> listVector = new Vector<String>();
String userName;
ObjectOutputStream out;
ObjectInputStream in;
HashMap<String,boolean[]> otherSeqsMap = new HashMap<String,boolean[]>();
ArrayList<Integer> trackList=null;
Sequencer sequencer;
Sequence sequence,mySequence;
Track track;
int []instruments={35,42,46,38,49,39,50,60,70,72,64,56,59,47,67,63};
{new BeatBox().startUp();}
10
public void startUp()
{
// open connection to the server
try
{
Socket sock = new Socket("127.0.0.1",4242);
out = new ObjectOutputStream(sock.getOutputStream());
in = new ObjectInputStream(sock.getInputStream());
Thread remote = new Thread(new RemoteReader());
remote.start();
}
catch(Exception ex){
System.out.println("Could not access server");
}
theFrame=new JFrame("Groove Studio");
//theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Dimension f = theFrame.getSize();
int x = (d.width - f.width) / 2;
int y = (d.height - f.height) / 2;
theFrame.setBounds(x, y, f.width, f.height );
Image img = Toolkit.getDefaultToolkit().getImage("logo.gif");
theFrame.setIconImage(img);
panel = new JPanel();
t= new JTextField("Enter your name");
t.addActionListener(new textListener());
t.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if(e.getButton()==MouseEvent.BUTTON1)
{t.setText("");}
}
}
);
panel.add(t);
theFrame.add(panel);
theFrame.setSize(75,75);
theFrame.setVisible(true);
}
11
theFrame.setVisible(false);
userName=t.getText();
setUpMidi();
buildGUI();
}
}
background=new JPanel(layout);
background.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
Color col=new Color(235,243,239);
checkboxList=new ArrayList<JCheckBox>();
temp=new JLabel("Tempo");
Font newLabelFont=new Font(temp.getFont().getName(),temp.getFont().getStyle(),12);
temp.setFont(newLabelFont);
float tempoFactor=sequencer.getTempoFactor();
tempoFactor = (float) (Math.round(tempoFactor*100.0f)/100.0f);
String s=new Float(tempoFactor).toString();
12
temp.setText(s +"BPM");
temp.setForeground(Color.BLACK);
buttonbox.add(temp);
13
grid.setVgap(1);
grid.setHgap(1);
mainPanel= new JPanel(grid) ;
background.add(BorderLayout.CENTER, mainPanel);
background.setOpaque(true);
mainPanel.setOpaque(true);
mainPanel.setBackground(Color.BLACK);
for(int i=0;i<256;i++)
{ImageIcon l = new ImageIcon("back.gif");
JCheckBox c=new JCheckBox();
c.setSelected(false);
c.setBackground(Color.BLACK);
checkboxList.add(c);
mainPanel.add(c);
}
JPopupMenu.setDefaultLightWeightPopupEnabled(false);
ImageIcon imageBack = new ImageIcon("back.gif");
JLabel b1= new JLabel(imageBack);
b1.setBounds(0, 0, imageBack.getIconWidth(), imageBack.getIconHeight());
theFrame.getLayeredPane().add(b1, new Integer(Integer.MIN_VALUE));
theFrame.setContentPane(background);
theFrame.setBounds(50,50,30,30);
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenu toolMenu = new JMenu("Tools");
fileMenu.add(newMenuItem);
fileMenu.add(openMenuItem);
14
fileMenu.add(saveMenuItem);
toolMenu.add(clearMenuItem);
toolMenu.add(restoreMenuItem);
toolMenu.add(aboutusMenuItem);
menuBar.add(fileMenu);
menuBar.add(toolMenu);
theFrame.setJMenuBar(menuBar);
theFrame.pack();
theFrame.setVisible(true);
}//close buildGUI
else
trackList.add(new Integer(0));//because this slot must be empty
\ }//close inner loop
makeTracks(trackList);
}// close outerloop
track.add(makeEvent(192,9,1,0,15));
try
{ sequencer.setSequence(sequence);
sequencer.setLoopCount(sequencer.LOOP_CONTINUOUSLY);
15
sequencer.start();
sequencer.setTempoInBPM(120) ;
mySequence=sequence;
}
catch(Exception e) {}
}
public void actionPerformed(ActionEvent event)
{}
class clearMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
for(int i=0;i<16;i++)
{
for(int j=0;j<16;j++)
{
JCheckBox jc=(JCheckBox)checkboxList.get((j*16)+i);
jc.setSelected(false);
sequencer.stop();
}
}
}
}
16
}
try {
FileOutputStream fileStream = new FileOutputStream(file);
ObjectOutputStream os = new ObjectOutputStream(fileStream);
os.writeObject(checkboxState);
os.close();
}
catch(Exception ex)
{ex.printStackTrace();}
}
class newMenuListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
for(int i=0;i<16;i++)
{
for(int j=0;j<16;j++)
{
JCheckBox jc=(JCheckBox)checkboxList.get((j*16)+i);
jc.setSelected(false);
sequencer.stop();
}
}
}
}
17
if(checkboxState[i])
check.setSelected(true);
else
check.setSelected(false);
}
sequencer.stop();
buildTrackandStart();
}
class MyStartListener implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
buildTrackandStart();
mySequence = sequence;
}
}
}
}
18
}
}
class userListener implements ActionListener
{
public void actionPerformed (ActionEvent a)
{ //make an arraylist of the state of checkboxes
boolean [] checkboxState = new boolean[256];
19
class RemoteReader implements Runnable
{
boolean[] checkboxState = null;
String nameToShow = null;
Object obj = null;
public void run()
{
try
{ while((obj=in.readObject()) != null)
{
System.out.println("got an Object from server");
System.out.println(obj.getClass());
nameToShow = (String) obj;
checkboxState = (boolean[]) in.readObject();
otherSeqsMap.put(nameToShow,checkboxState);
listVector.add(nameToShow);
incomingList.setListData(listVector);
catch(Exception e)
{e.printStackTrace();}
{
public void actionPerformed(ActionEvent e)
{
if(mySequence != null)
{
sequence = mySequence; // restore to original
}
20
}
{
for(int i = 0;i < 256;i++)
{
JCheckBox check = (JCheckBox) checkboxList.get(i);
if(checkboxState[i])
{
check.setSelected(true);
}
else
{
check.setSelected(false);
}
}
21
}
catch(Exception e){}
return(event);
}
import java.io.*;
import java.net.*;
import java.util.*;
22
public void run()
{
Object o1=null;
Object o2=null;
try
{
while((o1 = in.readObject()) != null)
{
o2 = in.readObject();
System.out.println("Read Two Objects");
tellEveryone(o1,o2);
}
}
catch(Exception e){e.printStackTrace();}
}//close run
}//close inner class
public void go()
{
clientOutputStreams = new ArrayList<ObjectOutputStream>();
try
{
ServerSocket serverSock = new ServerSocket(4242);
while(true)
{
Socket clientSocket = serverSock.accept();
ObjectOutputStream out = new
ObjectOutputStream(clientSocket.getOutputStream());
clientOutputStreams.add(out);
Thread t = new Thread(new ClientHandler(clientSocket));
t.start();
System.out.println("Got Connected");
}
}catch(Exception e){e.printStackTrace();}
}//close go
public void tellEveryone(Object one, Object two)
{
Iterator it = clientOutputStreams.iterator();
while(it.hasNext())
{
try
{ ObjectOutputStream out = (ObjectOutputStream) it.next();
out.writeObject(one);
out.writeObject(two);
}
catch(Exception e){e.printStackTrace();}
23
}
}//close class.
24
Testing Strategies
It should be clear in mind that philosophy behind testing is to find errors. Test cases are devised
with this purpose in mind. A test case is a set of data that the system will process as normal
input. However, the data are created with the express intent of determining whether the system
will process them correctly. Each test case is designed with the intent of finding errors in the way
the system will process it. There are two general strategies for testing software:
• Code testing
• Specification testing
In code testing, the analyst develops those cases to execute every instructions and path in a
program. Under specification testing, the analyst examines the program specifications and then
writes test data to determine how the program operates under specific conditions.
Systems are not designed as entire systems nor are they tested as single systems. The analyst
must perform both unit and system testing.
25
Black box testing tries to find errors in the following categories:
26
Screenshots
Original Interface
Chat Interface
27
28
Conclusion
This project has huge scope for further development using various features from Java Media
Framework it can be converted into a complete media player with a chat interface also it has an
online implementation whereby it can be placed as an online application connecting users from
varied part of the world. Also as every user enjoys music it can be used as an alternative to mp3
player. Additional features that can be provided can be video play user account creation, saving
playlists.
References
• http://www.java2s.com/Tutorial/Java/.htm..................October,2010
• http://home.cogeco.ca/~ve3ll/jatutor0.htm.................. October,2010
• http://download.oracle.com/javase/tutorial/................ October,2010
29