Skip to content

Commit

Permalink
Fix Issue #267 Drums transform RP: mix knobs should impact the transf…
Browse files Browse the repository at this point in the history
…ormed phrase, not the original phrase
  • Loading branch information
jjazzboss committed Jan 29, 2022
1 parent 4686b38 commit 4d210c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
8 changes: 4 additions & 4 deletions Options/src/org/jjazz/options/MidiPanel.form
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Component id="lbl_midiInNote" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbl_inNote" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="162" max="32767" attributes="0"/>
<Component id="btn_refreshIn" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane4" alignment="0" max="32767" attributes="0"/>
Expand All @@ -71,8 +71,8 @@
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane3" pref="101" max="32767" attributes="0"/>
<Component id="jScrollPane4" pref="101" max="32767" attributes="0"/>
<Component id="jScrollPane3" pref="23" max="32767" attributes="0"/>
<Component id="jScrollPane4" pref="23" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
Expand Down Expand Up @@ -305,7 +305,7 @@
<Component id="btn_learn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btn_reset" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="17" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
Expand Down
8 changes: 4 additions & 4 deletions Options/src/org/jjazz/options/MidiPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
.addComponent(btn_learn)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btn_reset)
.addGap(0, 17, Short.MAX_VALUE)))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())))))
);
pnl_remoteControlLayout.setVerticalGroup(
Expand Down Expand Up @@ -530,7 +530,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
.addComponent(lbl_midiInNote)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lbl_inNote)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 162, Short.MAX_VALUE)
.addComponent(btn_refreshIn))
.addComponent(jScrollPane4)
.addComponent(pnl_remoteControl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
Expand All @@ -546,8 +546,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt)
.addComponent(lbl_InDevices))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE)
.addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* A RhythmParameter value to transform a drums phrase.
* <p>
* Always contains a DrumsMixTransform() at first position in the transform chain.
* Always contains a DrumsMixTransform() at last position in the transform chain.
*/
public class RP_SYS_DrumsTransformValue
{
Expand Down Expand Up @@ -59,13 +59,13 @@ public RhythmVoice getRhythmVoice()
/**
* Return a copy of this object but with the specified chain.
*
* @param chain If null, the returned copy will use the default value. If not null, the first PhraseTransform must be a
* DrumsMixTransform instance.
* @param chain If null, the returned copy will use the default value. If not null, the last PhraseTransform must be a
* DrumsMixTransform instance.
* @return
*/
public RP_SYS_DrumsTransformValue getCopy(PhraseTransformChain chain)
{
checkArgument(chain == null || (!chain.isEmpty() && chain.get(0) instanceof DrumsMixTransform), "chain=%s", chain);
checkArgument(chain == null || (!chain.isEmpty() && chain.get(chain.size() - 1) instanceof DrumsMixTransform), "chain=%s", chain);
var res = new RP_SYS_DrumsTransformValue(rhythmVoice);
res.transformChain = chain == null ? new PhraseTransformChain(Arrays.asList(new DrumsMixTransform())) : chain.deepClone();
return res;
Expand All @@ -74,22 +74,22 @@ public RP_SYS_DrumsTransformValue getCopy(PhraseTransformChain chain)
/**
* Get a copy of the chain associated to rv.
*
* @param excludeDrumsMixTransform If true do not include in the return value the DrumsMixTransform at first position
* @param excludeDrumsMixTransform If true do not include in the return value the DrumsMixTransform at last position
* @return Can't be null
*/
public PhraseTransformChain getTransformChain(boolean excludeDrumsMixTransform)
{
var res = transformChain.deepClone();
if (excludeDrumsMixTransform)
if (excludeDrumsMixTransform && !res.isEmpty())
{
res.remove(0);
res.remove(res.size() - 1);
}
return res;
}

public DrumsMixTransform getDrumsMixTransform()
{
return (DrumsMixTransform) transformChain.get(0);
return (DrumsMixTransform) transformChain.get(transformChain.size() - 1);
}


Expand Down Expand Up @@ -119,7 +119,7 @@ static public String saveAsString(RP_SYS_DrumsTransformValue v)
* Create an object from a string.
*
* @param rv Must have a container defined and be of RhythmVoice.Type.DRUMS
* @param s Example "[uniqueId1#prop1=value1,prop2=value2|uniqueId2#|uniqueId3#prop1=value1]"
* @param s Example "[uniqueId1#prop1=value1,prop2=value2|uniqueId2#|uniqueId3#prop1=value1]"
* @return Can be null
* @see #saveAsString(org.jjazz.phrasetransform.api.rps.RP_SYS_DrumsTransformValue)
* @see PhraseTransformChain#loadFromString(java.lang.String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ private PhraseTransformChain buildChainFromUI()
{
var res = new PhraseTransformChain();

List<PhraseTransform> pts = Utilities.getListModelAsList(list_transformChainModel);
res.addAll(pts);

// Add the drums mix transform AFTER the transformation chain: it's more natural for user
var dmt = new DrumsMixTransform();
dmt.setBassDrumOffset(knb_bassDrum.getValue());
dmt.setSnareOffset(knb_snare.getValue());
Expand All @@ -378,9 +382,7 @@ private PhraseTransformChain buildChainFromUI()
dmt.setHiHatOffset(knb_hihat.getValue());
res.add(dmt);

List<PhraseTransform> pts = Utilities.getListModelAsList(list_transformChainModel);
res.addAll(pts);


return res;
}

Expand Down

0 comments on commit 4d210c8

Please sign in to comment.