Skip to content

Commit

Permalink
Implement Issue #324 Add a "NC" chord symbol, which makes no sound
Browse files Browse the repository at this point in the history
  • Loading branch information
jjazzboss committed Dec 4, 2022
1 parent aacefe8 commit 7eb6fd9
Show file tree
Hide file tree
Showing 35 changed files with 643 additions and 351 deletions.
4 changes: 2 additions & 2 deletions Arranger/src/org/jjazz/arranger/Arranger.java
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public void updateChordSymbol(ChordSymbol newCs)

// Prepare the new CLI_ChordSymbol
var firstEcs = firstChordSymbol.getData();
var newEcs = new ExtChordSymbol(newCs, firstEcs.getRenderingInfo(), firstEcs.getAlternateChordSymbol(), firstEcs.getAlternateFilter());
var newEcs = firstEcs.getCopy(newCs, null, null, null);
CLI_ChordSymbol newCliCs = CLI_Factory.getDefault().createChordSymbol(cls, newEcs, firstChordSymbol.getPosition());


Expand Down Expand Up @@ -418,7 +418,7 @@ private SongContext buildWorkContext(SongContext sgContext, SongPart spt, int ma
if (clis.isEmpty())
{
// Add a "C" chord symbol at the start of the section
ExtChordSymbol ecs = new ExtChordSymbol(new Note(0), ChordTypeDatabase.getInstance().getChordType(0));
ExtChordSymbol ecs = new ExtChordSymbol(new Note(0), new Note(0), ChordTypeDatabase.getInstance().getChordType(0));
CLI_ChordSymbol cliCs = CLI_Factory.getDefault().createChordSymbol(clsWork, ecs, cliSection.getPosition());
clsWork.addItem(cliCs);

Expand Down
16 changes: 10 additions & 6 deletions CL_Editor/src/org/jjazz/ui/cl_editor/actions/AccentCrash.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void actionPerformed(ActionEvent ev)
if (cri.hasOneFeature(Feature.ACCENT, Feature.ACCENT_STRONGER))
{
ChordRenderingInfo newCri = next(cri);
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);
}
}
Expand Down Expand Up @@ -219,12 +219,16 @@ private class MyMenuItem extends JMenuItem implements DynamicMenuContent

public MyMenuItem()
{
cbm_crash = new JCheckBoxMenuItem(ResUtil.getString(getClass(),"CrashAlways", new Object[] {}));
cbm_crash = new JCheckBoxMenuItem(ResUtil.getString(getClass(), "CrashAlways", new Object[]
{
}));
cbm_crash.setAccelerator(KeyStroke.getKeyStroke('H'));
cbm_crash.addItemListener(evt -> setCrash(evt.getStateChange() == ItemEvent.SELECTED));
cbm_crash.putClientProperty("CheckBoxMenuItem.doNotCloseOnMouseClick", true);

cbm_noCrash = new JCheckBoxMenuItem(ResUtil.getString(getClass(),"CrashNever", new Object[] {}));
cbm_noCrash = new JCheckBoxMenuItem(ResUtil.getString(getClass(), "CrashNever", new Object[]
{
}));
cbm_noCrash.setAccelerator(KeyStroke.getKeyStroke('H'));
cbm_noCrash.addItemListener(evt -> setNoCrash(evt.getStateChange() == ItemEvent.SELECTED));
cbm_noCrash.putClientProperty("CheckBoxMenuItem.doNotCloseOnMouseClick", true);
Expand Down Expand Up @@ -302,23 +306,23 @@ private void changeSelectedChordSymbols(int state)
features.remove(Feature.CRASH);
features.remove(Feature.NO_CRASH);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

} else if (state == 1 && !features.contains(Feature.CRASH))
{
features.remove(Feature.NO_CRASH);
features.add(Feature.CRASH);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

} else if (state == 2 && !features.contains(Feature.NO_CRASH))
{
features.remove(Feature.CRASH);
features.add(Feature.NO_CRASH);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void actionPerformed(ActionEvent ev)
if (cri.hasOneFeature(Feature.ACCENT, Feature.ACCENT_STRONGER))
{
ChordRenderingInfo newCri = next(cri);
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);
}
}
Expand Down Expand Up @@ -214,15 +214,15 @@ private void setAccent(boolean stronger)
features.remove(Feature.ACCENT);
features.add(Feature.ACCENT_STRONGER);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

} else if (!stronger && features.contains(Feature.ACCENT_STRONGER))
{
features.remove(Feature.ACCENT_STRONGER);
features.add(Feature.ACCENT);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void actionPerformed(ActionEvent ev)
if (cri.hasOneFeature(Feature.HOLD, Feature.SHOT))
{
ChordRenderingInfo newCri = next(cri);
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);
}
}
Expand Down Expand Up @@ -235,14 +235,14 @@ private void setExtended(boolean extended)
{
features.add(Feature.EXTENDED_HOLD_SHOT);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

} else if (!extended && features.contains(Feature.EXTENDED_HOLD_SHOT))
{
features.remove(Feature.EXTENDED_HOLD_SHOT);
ChordRenderingInfo newCri = new ChordRenderingInfo(features, cri.getScaleInstance());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void actionPerformed(ActionEvent ev)
{
ExtChordSymbol ecs = item.getData();
ChordRenderingInfo newCri = next(ecs.getRenderingInfo());
ExtChordSymbol newCs = new ExtChordSymbol(ecs, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
ExtChordSymbol newCs = ecs.getCopy(null, newCri, ecs.getAlternateChordSymbol(), ecs.getAlternateFilter());
item.getContainer().changeItem(item, newCs);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.jjazz.ui.cl_editor.api.CL_Editor;
import org.jjazz.ui.cl_editor.api.CL_EditorTopComponent;
import org.jjazz.ui.cl_editor.api.CL_SelectionUtilities;
import org.jjazz.ui.cl_editor.barbox.api.BarBox;
import org.jjazz.ui.itemrenderer.api.IR_Type;
import org.jjazz.ui.itemrenderer.api.ItemRenderer;
import org.openide.awt.ActionID;
Expand Down
16 changes: 6 additions & 10 deletions CL_Editor/src/org/jjazz/ui/cl_editor/actions/SetChordType.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import javax.swing.AbstractAction;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import org.jjazz.harmony.api.ChordSymbol;
import org.jjazz.harmony.api.ChordType;
import org.jjazz.harmony.api.ChordTypeDatabase;
import org.jjazz.harmony.api.StandardScaleInstance;
Expand All @@ -44,7 +45,6 @@
import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences;
import org.openide.awt.ActionRegistration;
import org.openide.util.NbBundle.Messages;
import org.openide.util.actions.Presenter;

/**
Expand All @@ -56,10 +56,6 @@
{
@ActionReference(path = "Actions/ChordSymbol", position = 200)
})
@Messages(
{

})
public final class SetChordType extends AbstractAction implements Presenter.Menu, Presenter.Popup
{

Expand Down Expand Up @@ -152,11 +148,11 @@ private void changeChordType(CL_Editor editor, ChordType ct)
for (ChordLeadSheetItem<?> item : selection.getSelectedItems())
{
CLI_ChordSymbol cliCs = (CLI_ChordSymbol) item;
ExtChordSymbol oldCs = cliCs.getData();
ChordRenderingInfo cri = oldCs.getRenderingInfo();
ChordRenderingInfo newCri = new ChordRenderingInfo(cri, (StandardScaleInstance) null); // Discard scale
ExtChordSymbol newCs = new ExtChordSymbol(oldCs.getRootNote(), oldCs.getBassNote(), ct, newCri, oldCs.getAlternateChordSymbol(), oldCs.getAlternateFilter());
editor.getModel().changeItem(cliCs, newCs);
ExtChordSymbol oldEcs = cliCs.getData();
ChordSymbol newCs = new ChordSymbol(oldEcs.getRootNote(), oldEcs.getBassNote(), ct);
ChordRenderingInfo newCri = new ChordRenderingInfo(oldEcs.getRenderingInfo(), (StandardScaleInstance) null); // Discard scale
ExtChordSymbol newEcs = oldEcs.getCopy(newCs, newCri, null, null);
editor.getModel().changeItem(cliCs, newEcs);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public PrefSizePanel()
ChordLeadSheetItem<?> item = null;
try
{
item = clif.createChordSymbol(null, new ExtChordSymbol("C7#9"), new Position(0, 0));
item = clif.createChordSymbol(null, ExtChordSymbol.get("C7#9"), new Position(0, 0));
} catch (ParseException ex)
{
Exceptions.printStackTrace(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public PrefSizePanel()
ChordLeadSheetItem<?> item1 = null, item2;
try
{
item1 = clif.createChordSymbol(null, new ExtChordSymbol("C#7#9b5"), new Position(0, 0));
item1 = clif.createChordSymbol(null, ExtChordSymbol.get("C#7#9b5"), new Position(0, 0));
} catch (ParseException ex)
{
Exceptions.printStackTrace(ex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void preset(String title, CLI_ChordSymbol cliCs, char key, boolean enable
// It's a Void alternate chord symbol
cb_useVoidAlt.setSelected(true);
// If user unselects the Void value, propose a value consistent with the current chord symbol
altChordSymbol = new AltExtChordSymbol(ecs.getRootNote(), ecs.getBassNote(), ecs.getChordType(), ecs.getRenderingInfo());
altChordSymbol = new AltExtChordSymbol(ecs, ecs.getRenderingInfo());
} else
{
cb_useVoidAlt.setSelected(false);
Expand All @@ -193,7 +193,7 @@ public void preset(String title, CLI_ChordSymbol cliCs, char key, boolean enable
{
// No alternate define, just set consistent values if ever user enables the alternate chord symbol
cb_enableAlternate.setSelected(false);
altChordSymbol = new AltExtChordSymbol(ecs.getRootNote(), ecs.getBassNote(), ecs.getChordType(), ecs.getRenderingInfo());
altChordSymbol = new AltExtChordSymbol(ecs, ecs.getRenderingInfo());
altFilter = new AltDataFilter(AltDataFilter.Random.RANDOM);
cb_useVoidAlt.setSelected(false);
}
Expand Down Expand Up @@ -268,7 +268,7 @@ public ExtChordSymbol getData()
ExtChordSymbol ecs = null;
try
{
ecs = new ExtChordSymbol(text, cri, getAltChordSymbol(), getAltFilter());
ecs = ExtChordSymbol.get(text, cri, getAltChordSymbol(), getAltFilter());
} catch (ParseException ex)
{
throw new IllegalStateException("text=" + text + " :" + ex.getMessage()); //NOI18N
Expand Down Expand Up @@ -396,7 +396,7 @@ private boolean checkChordSymbol()
{
if (!text.isEmpty())
{
ecs = new ExtChordSymbol(text);
ecs = ExtChordSymbol.get(text);
checkOk = true;
}
} catch (ParseException ex)
Expand Down Expand Up @@ -1149,7 +1149,7 @@ private void btn_setAltChordSymbolActionPerformed(java.awt.event.ActionEvent evt
if (ALT_INSTANCE.exitedOk())
{
ExtChordSymbol ecs = ALT_INSTANCE.getData();
altChordSymbol = new AltExtChordSymbol(ecs.getRootNote(), ecs.getBassNote(), ecs.getChordType(), ecs.getRenderingInfo());
altChordSymbol = new AltExtChordSymbol(ecs, ecs.getRenderingInfo());
lbl_altChordSymbol.setText(altChordSymbol.toString());
lbl_optionalAltText.setText(getAltOptionalText(getAltChordSymbol(), getAltFilter()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,37 +90,37 @@ public ChordLeadSheet createSampleLeadSheet12bars(String sectionName, int size)
CLI_Factory clif = CLI_Factory.getDefault();
try
{
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Dm7"), new Position(0, 0)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("C-7"), new Position(0, 2f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("F#7"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Dm7"), new Position(0, 0)));
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("C-7"), new Position(0, 2f)));
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("F#7"),
new Position(1, 0)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Bbmaj7#5"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Bbmaj7#5"),
new Position(1, 2)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("A"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("A"),
new Position(1, 3f)));
cls.addSection(clif.createSection(cls, "Chorus", TimeSignature.THREE_FOUR, 2));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("D7b9b5"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("D7b9b5"),
new Position(2, 1f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("FM7#11"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("FM7#11"),
new Position(4, 3f)));
cls.addSection(clif.createSection(cls, "Bridge", TimeSignature.FOUR_FOUR, 5));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Eb7b9#5"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Eb7b9#5"),
new Position(5, 0.75f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Ab7#11"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Ab7#11"),
new Position(6, 0)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("A#"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("A#"),
new Position(6, 4f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("F7alt"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("F7alt"),
new Position(6, 1.5f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("G7#9#5"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("G7#9#5"),
new Position(7, 2f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("G#7dim"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("G#7dim"),
new Position(8, 0f)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Dbmaj7"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Dbmaj7"),
new Position(8, 2)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("Gbmaj7"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("Gbmaj7"),
new Position(9, 0)));
cls.addItem(clif.createChordSymbol(cls, new ExtChordSymbol("G#maj7"),
cls.addItem(clif.createChordSymbol(cls, ExtChordSymbol.get("G#maj7"),
new Position(11, 3f)));
} catch (ParseException | UnsupportedEditException ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

/**
* A filter used to decide whether the alternate data of a CLI_ChordSymbol should be used.
* <p>
* This is an immutable class.
*/
public class AltDataFilter implements Serializable
{
Expand Down
Loading

0 comments on commit 7eb6fd9

Please sign in to comment.