use of blue.soundObject.PolyObject in project blue by kunstmusik.
the class AutomationManager method layerGroupChanged.
@Override
public void layerGroupChanged(LayerGroupDataEvent event) {
if (event.getType() != LayerGroupDataEvent.DATA_REMOVED || !(event.getSource() instanceof PolyObject)) {
return;
}
final ArrayList<Layer> layers = event.getLayers();
if (layers == null) {
return;
}
for (Layer layer : layers) {
SoundLayer sLayer = (SoundLayer) layer;
ParameterIdList idList = sLayer.getAutomationParameters();
for (int i = 0; i < idList.size(); i++) {
String paramId = idList.getParameterId(i);
Parameter param = getParameter(paramId);
if (param != null) {
param.setAutomationEnabled(false);
}
}
}
}
use of blue.soundObject.PolyObject in project blue by kunstmusik.
the class AutomationManager method parameterRemoved.
public void parameterRemoved(Parameter param) {
allParameters.remove(param);
for (LayerGroup<? extends Layer> layerGroup : score) {
if (layerGroup instanceof PolyObject) {
PolyObject pObj = (PolyObject) layerGroup;
for (SoundLayer layer : pObj) {
ParameterIdList automationParameters = layer.getAutomationParameters();
String paramId = param.getUniqueId();
if (automationParameters.contains(paramId)) {
automationParameters.removeParameterId(paramId);
}
}
}
}
// dirty = true;
}
use of blue.soundObject.PolyObject in project blue by kunstmusik.
the class AutomationManager method parameterSelected.
/**
* When parameter is selected, check if this parameter is in use and if by
* this soundLayer, turn it off, otherwise move it to this soundLayer.
*
* @param soundLayer
* @param param
*/
private void parameterSelected(ParameterIdList paramIdList, Parameter param) {
String uniqueId = param.getUniqueId();
if (param.isAutomationEnabled()) {
if (paramIdList.contains(uniqueId)) {
param.setAutomationEnabled(false);
paramIdList.removeParameterId(uniqueId);
} else {
// TODO - This class needs further updating for generic
// LayerGroup Design
Score score = data.getScore();
for (LayerGroup<? extends Layer> layerGroup : score) {
if (!(layerGroup instanceof PolyObject)) {
continue;
}
PolyObject pObj = (PolyObject) layerGroup;
for (SoundLayer layer : pObj) {
if (layer.getAutomationParameters() == paramIdList) {
continue;
}
ParameterIdList automationParameters = layer.getAutomationParameters();
if (automationParameters.contains(uniqueId)) {
automationParameters.removeParameterId(uniqueId);
}
}
}
paramIdList.addParameterId(uniqueId);
}
} else {
param.setAutomationEnabled(true);
param.getLine().setColor(LineColors.getColor(paramIdList.size()));
paramIdList.addParameterId(uniqueId);
param.fireUpdateFromTimeChange();
}
}
use of blue.soundObject.PolyObject in project blue by kunstmusik.
the class MidiImportUtilities method convertMidiFile.
/**
* Converts a MIDI file to a blue polyObject. Will return null if unable to
* open or process the file.
*
* @param midiFile
* @return
* @throws NoteParseException
*/
public static PolyObject convertMidiFile(Frame root, File midiFile) throws NoteParseException {
if (midiFile == null || !midiFile.exists()) {
return null;
}
Sequence sequence = null;
try {
sequence = MidiSystem.getSequence(midiFile);
} catch (InvalidMidiDataException imde) {
imde.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
}
if (sequence == null) {
return null;
}
PolyObject pObj = new PolyObject(true);
Track[] tracks = sequence.getTracks();
double divType = sequence.getDivisionType();
if (divType == Sequence.PPQ) {
divType = 1.0f;
}
double ticksLength = (double) sequence.getResolution();
MidiImportSettings settings = getMidiImportSettings(tracks);
if (settings.getRowCount() == 0) {
return null;
}
boolean retVal = MidiImportSettingsDialog.ask(root, settings);
if (!retVal) {
return null;
}
for (int i = 0; i < tracks.length; i++) {
TrackImportSettings trSettings = settings.getTrackSettingsForTrackNum(i);
if (trSettings == null) {
continue;
}
Track track = tracks[i];
NoteList nl = getNoteListForTrack(track, divType, ticksLength, trSettings.getNoteTemplate(), trSettings.getInstrId());
if (nl == null || nl.size() == 0) {
continue;
}
GenericScore genSco = new GenericScore();
if (trSettings.isTrim()) {
// Assumes NoteList is already sorted
double start = nl.get(0).getStartTime();
genSco.setStartTime(start);
ScoreUtilities.normalizeNoteList(nl);
} else {
genSco.setStartTime(0.0f);
}
genSco.setSubjectiveDuration(ScoreUtilities.getTotalDuration(nl));
genSco.setText(nl.toString());
genSco.setName("Track " + i);
SoundLayer sLayer = pObj.newLayerAt(-1);
sLayer.add(genSco);
}
return pObj;
}
use of blue.soundObject.PolyObject in project blue by kunstmusik.
the class OpenProjectAction method reconcileAudioFiles.
private static void reconcileAudioFiles(PolyObject pObj, Map<String, String> map) {
for (SoundObject sObj : pObj.getSoundObjects(true)) {
if (sObj instanceof AudioFile) {
AudioFile af = (AudioFile) sObj;
String soundFileName = af.getSoundFileName();
if (map.containsKey(soundFileName)) {
af.setSoundFileName(map.get(soundFileName));
}
} else if (sObj instanceof PolyObject) {
reconcileAudioFiles((PolyObject) sObj, map);
}
}
}
Aggregations