Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,28 @@
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="OpenOMR" default="default" basedir=".">
<description>Builds, tests, and runs the project OpenOMR.</description>
<import file="nbproject/build-impl.xml"/>
<description>Builds, tests, and runs the project OpenOMR.</description>
<import file="nbproject/build-impl.xml"/>
<target name="-post-jar">
<copy todir="${dist.dir}">
<fileset dir=".">
<include name="icons/*"/>
<include name="neuralnetwork/**"/>
<include name="testImages/*"/>
<include name="lib/*.jar"/>
</fileset>
</copy>
</target>
<!--
<target name="-post-jar">
<jar update="yes" jarfile="${dist.jar}">
<zipfileset src="lib/jcommon-1.0.23.jar" includes="**"/>
<zipfileset src="lib/jfreechart-1.0.19.jar" includes="**"/>
<zipfileset src="lib/joone-engine.jar" includes="**"/>
</jar>
</target>
-->

<!--

There exist several targets which are by default empty and which can be
Expand Down Expand Up @@ -70,4 +90,4 @@
nbproject/build-impl.xml file.

-->
</project>
</project>
Binary file added icons/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/openomr/gui/GUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -1196,6 +1196,7 @@ public void setImageRecognisedOptions(boolean val)
symbolItem.setEnabled(val);
staveProjItem.setEnabled(val);
toolBar.setPlayEnbabled(true);
toolBar.setSaveEnbabled(true);
}

public void setBoundaryImage(BufferedImage dupImage)
Expand Down
41 changes: 41 additions & 0 deletions src/openomr/gui/ToolBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class ToolBar extends JPanel
private RecognitionAction recognitionAction;
private FFTAction fftAction;
private PlayAction playAction;
private SaveAction saveAction;
private JDialog recogDialog;
private OpenAction openAction;

Expand All @@ -70,11 +71,13 @@ public ToolBar(GUI gui)
recognitionAction = new RecognitionAction("Right", new ImageIcon("icons/GreenFlag.png"), "Perform Recognition", 'R');
fftAction = new FFTAction("Center", new ImageIcon("icons/Fft.png"), "Do FFT", 'C');
playAction = new PlayAction("Right", new ImageIcon("icons/Play.png"), "Play Recognized Score", 'R');
saveAction = new SaveAction("Right", new ImageIcon("icons/save.png"), "Save Recognized Score", 'S');
openAction = new OpenAction("Left", new ImageIcon("icons/Open.png"), "Open File", 'L');
toolbar.add(openAction);
toolbar.add(fftAction);
toolbar.add(recognitionAction);
toolbar.add(playAction);
toolbar.add(saveAction);
box.add(toolbar);
box.add(Box.createHorizontalGlue());

Expand Down Expand Up @@ -126,6 +129,39 @@ public void actionPerformed(ActionEvent arg0)
}
}

private class SaveAction extends AbstractAction
{
public SaveAction(String text, Icon icon, String description, char accelerator)
{
super(text, icon);
setEnabled(false);
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(accelerator, java.awt.Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
putValue(SHORT_DESCRIPTION, description);
}

public void actionPerformed(ActionEvent arg0)
{
ScoreGenerator scoreGen = null;
try
{
StaveDetection staveDetection = gui.getStaveDetection();
LinkedList<Staves> staveList = staveDetection.getStaveList();
scoreGen = new ScoreGenerator(staveList);
scoreGen.makeSong(64);
scoreGen.save();
}
catch (MidiUnavailableException e)
{
e.printStackTrace();
}
catch (InvalidMidiDataException e)
{
e.printStackTrace();
}
}
}


private class PlayAction extends AbstractAction
{
public PlayAction(String text, Icon icon, String description, char accelerator)
Expand Down Expand Up @@ -198,6 +234,11 @@ public void setPlayEnbabled(boolean val)
playAction.setEnabled(val);
}

public void setSaveEnbabled(boolean val)
{
saveAction.setEnabled(val);
}

public void setOpenEnabled(boolean val)
{
openAction.setEnabled(val);
Expand Down
25 changes: 21 additions & 4 deletions src/openomr/midi/MidiFileGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package openomr.midi;

import java.io.File;
import javax.sound.midi.*;

/**
Expand All @@ -32,6 +33,7 @@
public abstract class MidiFileGenerator
{
private final Sequencer sequencer;
private final Sequence sequence;
private final Track track;
private final int resolution;
private int pos;
Expand All @@ -45,9 +47,8 @@ public abstract class MidiFileGenerator
public MidiFileGenerator(int key, int tempo, int resolution) throws MidiUnavailableException, InvalidMidiDataException
{
this.resolution = resolution;
Sequence sequence = new Sequence(Sequence.PPQ, resolution);
this.sequence = new Sequence(Sequence.PPQ, resolution);
track = sequence.createTrack();
//makeSong(key);
sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
Expand All @@ -59,7 +60,23 @@ public void start()
sequencer.start();
}

//protected abstract void makeSong(int key) throws InvalidMidiDataException;
public void save()
{

try{
File midifile = new File("generated.mid");
if (sequence != null){
MidiSystem.write(sequence,1,midifile);
System.out.println("File written: [generated.mid]");
}else{
System.out.println("null midi sequence found");
}
}

catch(Exception e){
System.out.println("Exception caught " + e.toString());
}
}

protected void add(int note) throws InvalidMidiDataException
{
Expand Down Expand Up @@ -109,4 +126,4 @@ private void addStopEvent(int note) throws InvalidMidiDataException
message.setMessage(ShortMessage.NOTE_OFF, 0, note, 0);
track.add(new MidiEvent(message, pos));
}
}
}
3 changes: 2 additions & 1 deletion src/openomr/midi/ScoreGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,5 @@ public void makeSong(int key) throws InvalidMidiDataException
//System.out.println("End Stave");
}
}
}

}