Skip to content

Commit

Permalink
音色設定関連のリファクタリング
Browse files Browse the repository at this point in the history
  • Loading branch information
110-kenichi committed Sep 8, 2019
1 parent 6a48d02 commit 5070517
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override object ConvertTo(ITypeDescriptorContext context, System.Globaliz
throw new ArgumentNullException("destinationType");

if (destinationType == typeof(string))
return context.PropertyDescriptor.PropertyType.Name + context.PropertyDescriptor.DisplayName;
return context.PropertyDescriptor.DisplayName;

return base.ConvertTo(context, culture, value, destinationType);
}
Expand Down
13 changes: 0 additions & 13 deletions src/mamidimemo/ComponentModel/MidiHookProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,6 @@ public override IMessage Invoke(IMessage msg)
{
res = RemotingServices.ExecuteMessage(this.f_Target, call);
}
//try
//{
// //メソッド前処理
// lockSlim.EnterWriteLock();

// //メソッド実行
// res = RemotingServices.ExecuteMessage(this.f_Target, call);
//}
//finally
//{
// //メソッド後処理
// lockSlim.ExitWriteLock();
//}
}

return res;
Expand Down
166 changes: 95 additions & 71 deletions src/mamidimemo/instruments/RP2A03.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ public override void KeyOn()
RP2A03WriteData(parentModule.UnitNumber, 0x15, (byte)(data | (1 << Slot)));

RP2A03WriteData(parentModule.UnitNumber, (uint)((Slot * 4) + 0x01),
(byte)(timbre.SQSweepEnable << 7 | timbre.SQSweepUpdateRate << 4 |
timbre.SQSweepDirection << 3 | timbre.SQSweepRange));
(byte)(timbre.SQSweep.Enable << 7 | timbre.SQSweep.UpdateRate << 4 |
timbre.SQSweep.Direction << 3 | timbre.SQSweep.Range));

//Volume
updateSqVolume();
Expand Down Expand Up @@ -672,7 +672,7 @@ public void UpdateNoisePitch()
int n = 31 - ((NoteOnEvent.NoteNumber + pitch) % 32);

var nt = timbre.NoiseType;
if (FxEngine.Active)
if (FxEngine != null && FxEngine.Active)
{
var eng = (NesFxEngine)FxEngine;
nt = (byte)(eng.DutyValue & 1);
Expand Down Expand Up @@ -760,7 +760,7 @@ public byte Volume

[DataMember]
[Category("Sound(SQ)")]
[Description("Square Envelope Decay Disable (0:Enable 1:Disable)")]
[Description("Square/Noise Envelope Decay Disable (0:Enable 1:Disable)")]
[DefaultValue((byte)1)]
public byte DecayDisable
{
Expand All @@ -777,6 +777,7 @@ public byte DecayDisable

private byte f_LengthDisable = 1;

[Browsable(false)]
[DataMember]
[Category("Sound(SQ/Tri)")]
[Description("Square/Tri Length Counter Clock Disable (0:Enable 1:Disable)")]
Expand All @@ -793,7 +794,7 @@ public byte LengthCounterDisable
}
}


/*
private byte f_NoiseEnvDecayEnable;
[DataMember]
Expand All @@ -810,6 +811,7 @@ public byte NoiseEnvDecayEnable
f_NoiseEnvDecayEnable = (byte)(value & 1);
}
}
*/

private byte f_SQDutyCycle;

Expand All @@ -828,73 +830,16 @@ public byte SQDutyCycle
}
}

private byte f_SQSweepEnable;

[DataMember]
[Category("Sound(SQ)")]
[Description("Square Sweep Enable (0:Disable 1:Enable)")]
public byte SQSweepEnable
{
get
{
return f_SQSweepEnable;
}
set
{
f_SQSweepEnable = (byte)(value & 1);
}
}


private byte f_SQSweepUpdateRate;

[DataMember]
[Category("Sound(SQ)")]
[Description("Square Sweep Update Rate (0-7)")]
public byte SQSweepUpdateRate
{
get
{
return f_SQSweepUpdateRate;
}
set
{
f_SQSweepUpdateRate = (byte)(value & 7);
}
}

private byte f_SQSweepDirection;

[DataMember]
[Category("Sound(SQ)")]
[Description("Wave Length (0:Decrease 1:Increse)")]
public byte SQSweepDirection
{
get
{
return f_SQSweepDirection;
}
set
{
f_SQSweepDirection = (byte)(value & 1);
}
}

private byte f_SQSweepRange;

/// <summary>
///
/// </summary>
[DataMember]
[Category("Sound(SQ)")]
[Description("Wave Length (0-7)")]
public byte SQSweepRange
[Description("Square Wave Sweep Settings")]
public SQSweepSettings SQSweep
{
get
{
return f_SQSweepRange;
}
set
{
f_SQSweepRange = (byte)(value & 7);
}
get;
private set;
}

private byte f_NoiseType;
Expand All @@ -917,6 +862,7 @@ public byte NoiseType

private byte f_PlayLength;

[Browsable(false)]
[DataMember]
[Category("Sound")]
[Description("Square/Tri Play Length (0-31)")]
Expand All @@ -935,6 +881,7 @@ public byte PlayLength

private byte f_TriCounterLength = 127;

[Browsable(false)]
[DataMember]
[Category("Sound(Tri)")]
[Description("Tri Linear Counter Length (0-127)")]
Expand Down Expand Up @@ -992,7 +939,8 @@ public byte DeltaPcmLoopEnable
/// </summary>
public RP2A03Timbre()
{
this.SDS.FxS = new NesFxSettings();
SQSweep = new SQSweepSettings();
SDS.FxS = new NesFxSettings();
}

/// <summary>
Expand All @@ -1018,7 +966,6 @@ public override void RestoreFrom(string serializeData)
}
}


}

[JsonConverter(typeof(NoTypeConverterJsonConverter<BasicFxSettings>))]
Expand Down Expand Up @@ -1180,6 +1127,83 @@ protected override void ProcessCore(SoundBase sound, bool isKeyOff, bool isSound

}

[JsonConverter(typeof(NoTypeConverterJsonConverter<SQSweepSettings>))]
[TypeConverter(typeof(CustomExpandableObjectConverter))]
[DataContract]
[MidiHook]
public class SQSweepSettings : ContextBoundObject
{

private byte f_Enable;

[DataMember]
[Category("Sound(SQ)")]
[Description("Square Sweep Enable (0:Disable 1:Enable)")]
public byte Enable
{
get
{
return f_Enable;
}
set
{
f_Enable = (byte)(value & 1);
}
}

private byte f_UpdateRate;

[DataMember]
[Category("Sound(SQ)")]
[Description("Square Sweep Update Rate (0-7)")]
public byte UpdateRate
{
get
{
return f_UpdateRate;
}
set
{
f_UpdateRate = (byte)(value & 7);
}
}

private byte f_Direction;

[DataMember]
[Category("Sound(SQ)")]
[Description("Wave Length (0:Decrease 1:Increse)")]
public byte Direction
{
get
{
return f_Direction;
}
set
{
f_Direction = (byte)(value & 1);
}
}

private byte f_Range;

[DataMember]
[Category("Sound(SQ)")]
[Description("Wave Length (0-7)")]
public byte Range
{
get
{
return f_Range;
}
set
{
f_Range = (byte)(value & 7);
}
}

}

/// <summary>
///
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion src/mamidimemo/instruments/YM2151.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,8 @@ public override void RestoreFrom(string serializeData)
[JsonConverter(typeof(NoTypeConverterJsonConverter<YM2151Operator>))]
[TypeConverter(typeof(CustomExpandableObjectConverter))]
[DataContract]
public class YM2151Operator
[MidiHook]
public class YM2151Operator : ContextBoundObject
{
private byte f_Enable = 1;

Expand Down
3 changes: 2 additions & 1 deletion src/mamidimemo/instruments/YM2413.cs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,8 @@ public enum ToneType
[TypeConverter(typeof(CustomExpandableObjectConverter))]
[JsonConverter(typeof(NoTypeConverterJsonConverter<YM2413Operator>))]
[DataContract]
public class YM2413Operator
[MidiHook]
public class YM2413Operator : ContextBoundObject
{

private byte f_AM;
Expand Down
3 changes: 2 additions & 1 deletion src/mamidimemo/instruments/YM2612.cs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ public override void RestoreFrom(string serializeData)
[TypeConverter(typeof(CustomExpandableObjectConverter))]
[JsonConverter(typeof(NoTypeConverterJsonConverter<YM2612Operator>))]
[DataContract]
public class YM2612Operator
[MidiHook]
public class YM2612Operator : ContextBoundObject
{
private byte f_Enable = 1;

Expand Down
3 changes: 2 additions & 1 deletion src/mamidimemo/instruments/YM3812.cs
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,8 @@ public override void RestoreFrom(string serializeData)
[TypeConverter(typeof(CustomExpandableObjectConverter))]
[JsonConverter(typeof(NoTypeConverterJsonConverter<YM3812Operator>))]
[DataContract]
public class YM3812Operator
[MidiHook]
public class YM3812Operator : ContextBoundObject
{

private byte f_AM;
Expand Down

0 comments on commit 5070517

Please sign in to comment.