com.frinika.project
Class ProjectContainer

java.lang.Object
  extended by com.frinika.project.ProjectContainer
All Implemented Interfaces:
EditHistoryRecorder<Lane>, MidiConsumer, java.io.Serializable

public class ProjectContainer
extends java.lang.Object
implements EditHistoryRecorder<Lane>, MidiConsumer, java.io.Serializable

Use to load Frinika projects. This class links together all components of a Frinika project, and provides all operations and features - including a Frinika sequencer instance. Information about Midi Devices - naming and how to reopen them is contained using the MidiDeviceDescriptors. Audio files are stored in a folder named audio which is created in the same folder as where the project is. Thus a good convention is to have one folder per project.

Author:
Peter Johan Salomonsen
See Also:
Serialized Form

Field Summary
 int compression_level
          Save project to a file
 
Constructor Summary
ProjectContainer()
          Create empty project
ProjectContainer(int ticksPerBeat)
           
ProjectContainer(javax.sound.midi.Sequence seq)
          Import a Sequence (e.g.
ProjectContainer(javax.sound.midi.Sequence seq, javax.sound.midi.MidiDevice midiDevice)
           
ProjectContainer(javax.sound.midi.Sequence seq, javax.sound.midi.MidiDevice midiDevice, boolean adjustPPQ)
           
 
Method Summary
 void add(int index, Lane lane)
           
 void add(Lane lane)
          adds a lane to the project and updates the history
 MidiDeviceDescriptor addMidiOutDevice(javax.sound.midi.MidiDevice midiDev)
          Add a midi device to the project.
 uk.org.toot.audio.mixer.MixControls addMixerInput(uk.org.toot.audio.core.AudioProcess audioProcess, java.lang.String string)
           
 void buildMidiIndex()
           
 MyClipboard clipBoard()
           
 void close()
          Close the project
static void closeAllMidiOutDevices()
           
 AudioLane createAudioLane()
          Creates a AudioLane and adds it to the Lane collection
 MidiLane createMidiLane()
          Creates a MidiLane and adds it to the Lane collection
 void createMidiLanesFromSequence(javax.sound.midi.Sequence seq, javax.sound.midi.MidiDevice midiDevice)
           
 void createSequence()
          Creates a sequence based on the resolution defined in ticksPerQuarterNote
 SynthLane createSynthLane(MidiDeviceDescriptor desc)
           
 TextLane createTextLane()
          Creates a TextLane and adds it to the Lane collection
 long eventQuantize(long tick)
           
 uk.org.toot.audio.server.AudioClient getAudioClient()
           
 java.io.File getAudioDirectory()
           
 BufferedRandomAccessFileManager getAudioFileManager()
           
 uk.org.toot.audio.server.AudioServer getAudioServer()
           
 ControlResolver getControlResolver()
           
 java.lang.Long getDataBaseID()
           
 DragList getDragList()
           
 EditHistoryContainer getEditHistoryContainer()
           
 long getEndTick()
           
 java.io.File getFile()
           
 java.lang.String getGenres()
           
 java.util.List<Lane> getLanes()
           
 LaneSelection getLaneSelection()
           
 MidiDeviceDescriptor getMidiDeviceDescriptor(javax.sound.midi.MidiDevice midiDevice)
          Get the midi device descriptor for the given midi device
 java.util.List<MidiDeviceDescriptor> getMidiDeviceDescriptors()
           
 java.lang.Integer getMidiDeviceIndex(javax.sound.midi.MidiDevice midiDevice)
           
 MidiDeviceRouter getMidiDeviceRouter()
           
 MidiResource getMidiResource()
           
 MidiRouterSerialization getMidiRouterSerialization()
           
 MidiSelection getMidiSelection()
           
 uk.org.toot.audio.mixer.AudioMixer getMixer()
           
 uk.org.toot.audio.mixer.MixerControls getMixerControls()
           
 MultiEventSelection getMultiEventSelection()
           
 AudioInjector getOutputProcess()
           
 PartSelection getPartSelection()
           
 double getPartViewSnapQuantization()
           
 double getPianoRollSnapQuantization()
           
 int getPixelsPerRedraw()
           
 java.io.File getProjectFile()
          If this projectContainer was initialized by a project file -the return the file
 ProjectLane getProjectLane()
          Lanes can contain other lanes.
 FrinikaRenderer getRenderer()
           
 FrinikaScriptingEngine getScriptingEngine()
           
 SelectionFocusable getSelectionFocus()
           
 FrinikaSequence getSequence()
           
 FrinikaSequencer getSequencer()
           
 SoloManager getSoloManager()
           
 SynthRack getSynthRack()
           
 TempoList getTempoList()
          Getter for the tempoList
 FrinikaTrackWrapper getTempoTrack()
           
 int getTicksPerBeat()
           
 TimeSignatureList getTimeSignatureList()
           
 TimeUtils getTimeUtils()
           
 java.lang.String getTitle()
           
 void injectIntoOutput(uk.org.toot.audio.core.AudioProcess process)
          Mixer the process output with the main mix
 void installMidiDevices()
          Go through the mididevice descriptor map and install mididevices
 boolean isPartViewSnapQuantized()
           
 boolean isPianoRollSnapQuantized()
           
static ProjectContainer loadCompressedProject(java.io.File file)
           
static ProjectContainer loadProject(java.io.File file)
           
static ProjectContainer loadProject(java.io.InputStream inputStream)
           
 void message(java.lang.String string)
           
 double microsAtTick(double tick)
          translate ticks to microseconds
 long partQuantize(long tick)
           
 void processMidiMessageFromDevice(javax.sound.midi.MidiDevice.Info devInfo, javax.sound.midi.MidiMessage arg0, long arg1)
          Redirects midi events used for controls If not consumed event is sent to midiReciever.
 void rebuildGUI()
           
 java.util.Vector<Lane> recordableLaneList()
           
 void remove(Lane lane)
           
 void removeMidiOutDevice(javax.sound.midi.MidiDevice midiDevice)
          Remove a midiOutDevice from the project
 void removeStrip(java.lang.String name)
           
 void resetEndTick()
           
 void saveProject(java.io.File file)
           
 void setDataBaseID(java.lang.Long dataBaseID)
           
 void setEndTick(long tick)
           
 void setGenres(java.lang.String string)
          set song genres.
 void setPartViewSnapQuantization(double val)
           
 void setPartViewSnapQuantized(boolean val)
           
 void setPianoRollSnapQuantization(double val)
           
 void setPianoRollSnapQuantized(boolean val)
           
 void setPixelsPerRedraw(int i)
           
 void setSaveReferencedData(boolean saveReferencedData)
           
 void setSelectionFocus(SelectionFocusable focus)
           
 void setTempoInBPM(float tempo)
          Set the tempo of the first event in the tempo list
 void setTitle(java.lang.String t)
          Set the title of the song.
 double tickAtMicros(double micros)
          translate microsecond time to ticks
 double tickToSample(long tick)
           
 void validate()
          DEBUGING --- NOT FOR PUBLIC USE
 void validate(Lane parent)
          DEBUGING --- NOT FOR PUBLIC USE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

compression_level

public transient int compression_level
Save project to a file

Constructor Detail

ProjectContainer

public ProjectContainer(int ticksPerBeat)
                 throws java.lang.Exception
Throws:
java.lang.Exception

ProjectContainer

public ProjectContainer()
                 throws java.lang.Exception
Create empty project

Throws:
java.lang.Exception

ProjectContainer

public ProjectContainer(javax.sound.midi.Sequence seq)
                 throws java.lang.Exception
Import a Sequence (e.g. obtained from a MidiFile) into a new project

Parameters:
seq -
Throws:
java.lang.Exception

ProjectContainer

public ProjectContainer(javax.sound.midi.Sequence seq,
                        javax.sound.midi.MidiDevice midiDevice)
                 throws java.lang.Exception
Throws:
java.lang.Exception

ProjectContainer

public ProjectContainer(javax.sound.midi.Sequence seq,
                        javax.sound.midi.MidiDevice midiDevice,
                        boolean adjustPPQ)
                 throws java.lang.Exception
Parameters:
seq - sequence
midiDevice - assign tracks to mididevice.
adjustPPQ - recalculate the ticks if sequence PPQ is not the defualt.
Throws:
java.lang.Exception
Method Detail

getDataBaseID

public java.lang.Long getDataBaseID()

setDataBaseID

public void setDataBaseID(java.lang.Long dataBaseID)

getMidiDeviceRouter

public MidiDeviceRouter getMidiDeviceRouter()

getMidiRouterSerialization

public MidiRouterSerialization getMidiRouterSerialization()

setGenres

public void setGenres(java.lang.String string)
set song genres.

Parameters:
string - A colon seperate list of genre names.

getGenres

public java.lang.String getGenres()

setTitle

public void setTitle(java.lang.String t)
Set the title of the song.

Parameters:
t -

getTitle

public java.lang.String getTitle()
Returns:
title of the song or file name if title is null

processMidiMessageFromDevice

public void processMidiMessageFromDevice(javax.sound.midi.MidiDevice.Info devInfo,
                                         javax.sound.midi.MidiMessage arg0,
                                         long arg1)
Redirects midi events used for controls If not consumed event is sent to midiReciever.

Specified by:
processMidiMessageFromDevice in interface MidiConsumer
Parameters:
devInfo -
arg0 -
arg1 -

removeStrip

public void removeStrip(java.lang.String name)

addMixerInput

public uk.org.toot.audio.mixer.MixControls addMixerInput(uk.org.toot.audio.core.AudioProcess audioProcess,
                                                         java.lang.String string)

injectIntoOutput

public void injectIntoOutput(uk.org.toot.audio.core.AudioProcess process)
Mixer the process output with the main mix

Parameters:
process -

loadProject

public static ProjectContainer loadProject(java.io.File file)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

loadCompressedProject

public static ProjectContainer loadCompressedProject(java.io.File file)
                                              throws java.lang.Exception
Throws:
java.lang.Exception

loadProject

public static ProjectContainer loadProject(java.io.InputStream inputStream)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

saveProject

public void saveProject(java.io.File file)
                 throws java.io.IOException
Throws:
java.io.IOException

getLanes

public java.util.List<Lane> getLanes()
Returns:
Returns the lanes.

createAudioLane

public AudioLane createAudioLane()
Creates a AudioLane and adds it to the Lane collection

Returns:

createTextLane

public TextLane createTextLane()
Creates a TextLane and adds it to the Lane collection


getSequencer

public FrinikaSequencer getSequencer()
Returns:
Returns the sequencer.

createSequence

public void createSequence()
Creates a sequence based on the resolution defined in ticksPerQuarterNote


getSequence

public FrinikaSequence getSequence()
Returns:
Returns the sequence.

getRenderer

public FrinikaRenderer getRenderer()
Returns:
Returns the renderer.

getProjectFile

public java.io.File getProjectFile()
If this projectContainer was initialized by a project file -the return the file

Returns:

getMultiEventSelection

public MultiEventSelection getMultiEventSelection()
Returns:
Returns the multiEventSelection.

getPartSelection

public PartSelection getPartSelection()
Returns:
the Part selection container for this project.

getLaneSelection

public LaneSelection getLaneSelection()
Returns:
the Lane selection container for this project.

getMidiSelection

public MidiSelection getMidiSelection()
Returns:
the Midi selection container for this project.

getScriptingEngine

public FrinikaScriptingEngine getScriptingEngine()

getEditHistoryContainer

public EditHistoryContainer getEditHistoryContainer()
Returns:
the Edit history container for this project.

close

public void close()
Close the project


add

public void add(Lane lane)
adds a lane to the project and updates the history

Specified by:
add in interface EditHistoryRecorder<Lane>

add

public void add(int index,
                Lane lane)

remove

public void remove(Lane lane)
Specified by:
remove in interface EditHistoryRecorder<Lane>

getProjectLane

public ProjectLane getProjectLane()
Lanes can contain other lanes. A project is contained within a project lane.

Returns:
top level Lane that containes all others.

getSynthRack

public SynthRack getSynthRack()

getMidiResource

public MidiResource getMidiResource()

getTempoTrack

public FrinikaTrackWrapper getTempoTrack()

setTempoInBPM

public void setTempoInBPM(float tempo)
Set the tempo of the first event in the tempo list

Parameters:
tempo -

buildMidiIndex

public void buildMidiIndex()

installMidiDevices

public void installMidiDevices()
Go through the mididevice descriptor map and install mididevices


setSaveReferencedData

public void setSaveReferencedData(boolean saveReferencedData)

getMidiDeviceIndex

public java.lang.Integer getMidiDeviceIndex(javax.sound.midi.MidiDevice midiDevice)

getSelectionFocus

public SelectionFocusable getSelectionFocus()

setSelectionFocus

public void setSelectionFocus(SelectionFocusable focus)

clipBoard

public MyClipboard clipBoard()

rebuildGUI

public void rebuildGUI()

getPianoRollSnapQuantization

public double getPianoRollSnapQuantization()
Returns:
piano roll quantization in ticks

getPartViewSnapQuantization

public double getPartViewSnapQuantization()

setPianoRollSnapQuantization

public void setPianoRollSnapQuantization(double val)

setPartViewSnapQuantization

public void setPartViewSnapQuantization(double val)

isPianoRollSnapQuantized

public boolean isPianoRollSnapQuantized()

isPartViewSnapQuantized

public boolean isPartViewSnapQuantized()

setPianoRollSnapQuantized

public void setPianoRollSnapQuantized(boolean val)

setPartViewSnapQuantized

public void setPartViewSnapQuantized(boolean val)

eventQuantize

public long eventQuantize(long tick)

partQuantize

public long partQuantize(long tick)

getEndTick

public long getEndTick()

setEndTick

public void setEndTick(long tick)

validate

public void validate()
DEBUGING --- NOT FOR PUBLIC USE


validate

public void validate(Lane parent)
DEBUGING --- NOT FOR PUBLIC USE

Parameters:
parent -

resetEndTick

public void resetEndTick()

recordableLaneList

public java.util.Vector<Lane> recordableLaneList()

getFile

public java.io.File getFile()

getAudioDirectory

public java.io.File getAudioDirectory()
Returns:

addMidiOutDevice

public MidiDeviceDescriptor addMidiOutDevice(javax.sound.midi.MidiDevice midiDev)
                                      throws javax.sound.midi.MidiUnavailableException
Add a midi device to the project. The midi device will be added to the sequencer, and a descriptor of how to reopen the mididevice from a saved instance will be added. Extra information such as custom name and soundbank info is also part of the descriptor.

Parameters:
midiDev -
Throws:
javax.sound.midi.MidiUnavailableException

closeAllMidiOutDevices

public static void closeAllMidiOutDevices()

getMidiDeviceDescriptor

public MidiDeviceDescriptor getMidiDeviceDescriptor(javax.sound.midi.MidiDevice midiDevice)
Get the midi device descriptor for the given midi device

Parameters:
midiDevice -
Returns:

removeMidiOutDevice

public void removeMidiOutDevice(javax.sound.midi.MidiDevice midiDevice)
Remove a midiOutDevice from the project

Parameters:
midiDevice -

getMidiDeviceDescriptors

public java.util.List<MidiDeviceDescriptor> getMidiDeviceDescriptors()

getMixerControls

public uk.org.toot.audio.mixer.MixerControls getMixerControls()

getAudioServer

public uk.org.toot.audio.server.AudioServer getAudioServer()

getMixer

public uk.org.toot.audio.mixer.AudioMixer getMixer()

getOutputProcess

public AudioInjector getOutputProcess()

message

public void message(java.lang.String string)

createSynthLane

public SynthLane createSynthLane(MidiDeviceDescriptor desc)

getAudioFileManager

public BufferedRandomAccessFileManager getAudioFileManager()

getAudioClient

public uk.org.toot.audio.server.AudioClient getAudioClient()

createMidiLane

public MidiLane createMidiLane()
Creates a MidiLane and adds it to the Lane collection

Returns:

createMidiLanesFromSequence

public void createMidiLanesFromSequence(javax.sound.midi.Sequence seq,
                                        javax.sound.midi.MidiDevice midiDevice)

getDragList

public DragList getDragList()

getPixelsPerRedraw

public int getPixelsPerRedraw()

setPixelsPerRedraw

public void setPixelsPerRedraw(int i)

tickAtMicros

public double tickAtMicros(double micros)
translate microsecond time to ticks


microsAtTick

public double microsAtTick(double tick)
translate ticks to microseconds


getTempoList

public TempoList getTempoList()
Getter for the tempoList

Returns:
tempoList

getTimeSignatureList

public TimeSignatureList getTimeSignatureList()

getTicksPerBeat

public int getTicksPerBeat()

getTimeUtils

public TimeUtils getTimeUtils()
Returns:
a TimeUtils for this project

tickToSample

public double tickToSample(long tick)

getSoloManager

public SoloManager getSoloManager()

getControlResolver

public ControlResolver getControlResolver()