- Adjusted PWM threshold for better sound

- Better Sound Adjustment tool
- SpeedSelect fix
This commit is contained in:
tudnai
2021-06-02 14:31:36 -07:00
parent 0444a510e5
commit 0582c3db73
4 changed files with 61 additions and 46 deletions

View File

@@ -1466,10 +1466,11 @@
<slider key="view" verticalHuggingPriority="750" id="NiF-yM-eE0">
<rect key="frame" x="0.0" y="14" width="116" height="26"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
<sliderCell key="cell" continuous="YES" refusesFirstResponder="YES" state="on" alignment="left" minValue="1" maxValue="6" doubleValue="1" tickMarkPosition="above" numberOfTickMarks="6" allowsTickMarkValuesOnly="YES" sliderType="linear" id="9W8-sY-vjz"/>
<connections>
<action selector="SpeedSelect:" target="B8D-0N-5wS" id="5hj-pt-1k0"/>
</connections>
<sliderCell key="cell" continuous="YES" refusesFirstResponder="YES" state="on" alignment="left" minValue="1" maxValue="6" doubleValue="1" tickMarkPosition="above" numberOfTickMarks="6" allowsTickMarkValuesOnly="YES" sliderType="linear" id="9W8-sY-vjz">
<connections>
<action selector="SpeedSelected:" target="B8D-0N-5wS" id="hjq-Fu-6I7"/>
</connections>
</sliderCell>
</slider>
</toolbarItem>
<toolbarItem implicitItemIdentifier="8A3C9390-7708-47D4-A1AB-9B62DD2041C6" label="CRT" paletteLabel="CRT" tag="1" image="Old Monitor" id="7T3-aH-gLv">
@@ -1661,7 +1662,7 @@
</connections>
</window>
<connections>
<outlet property="SpeedSelector" destination="djd-zw-gXS" id="zit-FA-m8j"/>
<outlet property="SpeedSelector" destination="djd-zw-gXS" id="CsA-TF-ozP"/>
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
</connections>
</windowController>
@@ -2132,13 +2133,18 @@
<outlet property="QuickDisk_Disk1" destination="cth-H6-Drg" id="cFI-9E-kYv"/>
<outlet property="QuickDisk_Disk2" destination="yDH-Ob-i3N" id="hvi-ZC-Pk4"/>
<outlet property="hires" destination="LlM-EV-ruZ" id="E60-pA-HM1"/>
<outlet property="lab" destination="yIR-MN-Hdl" id="9SQ-AJ-W3E"/>
<outlet property="initialLeadEdgeSlider" destination="8yq-X9-qQ4" id="dnS-3t-7u1"/>
<outlet property="initialTailEdgeSlider" destination="P91-Ah-VX6" id="wv4-vA-j9E"/>
<outlet property="leadEdgeSlider" destination="Fux-hn-RBw" id="vCr-f0-g2Z"/>
<outlet property="leadingEdgeLabel" destination="aIi-wV-21w" id="fbe-gk-pI0"/>
<outlet property="ledingInitEdgeLabel" destination="Eaz-eQ-aTu" id="jsG-f0-dad"/>
<outlet property="lores" destination="Gqh-qw-fjy" id="vOE-5m-Jfi"/>
<outlet property="scanLines" destination="dGn-a4-c1t" id="3Xy-Ku-95P"/>
<outlet property="soundGapLabel" destination="yIR-MN-Hdl" id="aRe-Mw-oH1"/>
<outlet property="soundGapSlider" destination="64O-qO-cQV" id="2dt-yL-0Pq"/>
<outlet property="speedometer" destination="FBZ-dh-6Fs" id="L0v-RY-xwB"/>
<outlet property="splashScreen" destination="D0w-YC-YlJ" id="WJB-BH-5EP"/>
<outlet property="tailEdgeSlider" destination="Sn1-VZ-VjW" id="cEi-IA-fwl"/>
<outlet property="textDisplay" destination="ccC-Wu-3za" id="2AD-aQ-x6x"/>
<outlet property="textDisplayScroller" destination="ss1-M1-nGn" id="Bbp-M9-REy"/>
<outlet property="trailingEdgeLabel" destination="uUU-7X-My0" id="pa6-JG-81g"/>

View File

@@ -80,7 +80,7 @@ class ToolBarController: NSWindowController {
@IBOutlet weak var SpeedSelector: NSToolbarItem!
@IBAction func SpeedSelect(_ slider: NSSlider) {
@IBAction func SpeedSelected(_ slider: NSSliderCell) {
switch slider.intValue {
case 2:
ViewController.current?.setCPUClockSpeed(freq: 2)
@@ -103,7 +103,7 @@ class ToolBarController: NSWindowController {
SpeedSelector.label = "MAX Speed"
default:
ViewController.current?.setCPUClockSpeed(freq: 1.023)
ViewController.current?.setCPUClockSpeed(freq: 14.31818 / 14.0)
SpeedSelector.label = "1.023 MHz"
}
}

View File

@@ -1047,6 +1047,18 @@ class ViewController: NSViewController {
newUpdateTimer( timeInterval: 1 / Double(fps) )
// #endif
soundGapSlider.integerValue = Int(spkr_extra_buf)
ledingInitEdgeLabel.title = "ILE: " + String( SPKR_INITIAL_LEADING_EDGE )
initialLeadEdgeSlider.floatValue = SPKR_INITIAL_LEADING_EDGE
leadingEdgeLabel.title = "LE: " + String( SPKR_FADE_LEADING_EDGE )
leadEdgeSlider.floatValue = SPKR_FADE_LEADING_EDGE
trailingInitEdgeLabel.title = "ITE: " + String( SPKR_INITIAL_TRAILING_EDGE )
initialTailEdgeSlider.floatValue = SPKR_INITIAL_TRAILING_EDGE
trailingEdgeLabel.title = "TE: " + String( SPKR_FADE_TRAILING_EDGE )
tailEdgeSlider.floatValue = SPKR_FADE_TRAILING_EDGE
}
override func viewDidAppear() {
@@ -1061,49 +1073,40 @@ class ViewController: NSViewController {
MHz_6502 = freq
clk_6502_per_frm = UInt64( MHz_6502 * M / Double(fps) )
clk_6502_per_frm_set = clk_6502_per_frm
}
@IBAction func speedSelected(_ sender: NSButton) {
if ( sender.title == "MAX" ) {
setCPUClockSpeed(freq: 2000)
}
else if let freq = Double( sender.title ) {
setCPUClockSpeed(freq: freq)
// TODO: Probably this is not the best way to deal with the problem: To make sound continous independent of FPS and Freq
// TODO: Probably this is not the best way to deal with the problem: To make sound continous independent of FPS and Freq
// spkr_extra_buf = Int32( 780 / fps )
spkr_extra_buf = 26
switch freq {
case 2.0:
spkr_extra_buf = 0 // 26
switch freq {
case 2.0:
// spkr_extra_buf = Int32( Double(spkr_extra_buf) * 2.961538461538462 ) // normally it should come up as 77, but this way it is calculated with FPS
// spkr_extra_buf = 20
spkr_extra_buf = 88
break
case 4.0:
spkr_extra_buf = 88
break
case 4.0:
// spkr_extra_buf = Int32( Double(spkr_extra_buf) * 1.346153846153846 ) // normally it should come up as 35, but this way it is calculated with FPS
// spkr_extra_buf = 45
spkr_extra_buf = 20
break
default:
spkr_extra_buf = 20
break
default:
// spkr_extra_buf = Int32( 780 / fps ) // normally it should come up as 26, but this way it is calculated with FPS
spkr_extra_buf = 26
break
}
SoundGap.integerValue = Int(spkr_extra_buf)
spkr_extra_buf = 0 // 26
break
}
soundGapLabel.title = String( spkr_extra_buf )
soundGapSlider.integerValue = Int(spkr_extra_buf)
}
@IBOutlet weak var lab: NSTextFieldCell!
@IBOutlet weak var soundGapLabel: NSTextFieldCell!
@IBAction func extraBuf(_ sender: NSSlider) {
spkr_extra_buf = sender.intValue
lab.title = String( spkr_extra_buf )
soundGapLabel.title = String( spkr_extra_buf )
}
@IBOutlet weak var ledingInitEdgeLabel: NSTextFieldCell!
@@ -1172,12 +1175,18 @@ class ViewController: NSViewController {
setSimulationMode(mode: sender.selectedItem?.title ?? "Normal" )
}
@IBOutlet weak var SoundGap: NSTextFieldCell!
@IBAction func SoundGapChanged(_ sender: NSStepper) {
SoundGap.integerValue = sender.integerValue
spkr_extra_buf = Int32( sender.integerValue )
}
@IBOutlet weak var initialLeadEdgeSlider: NSSlider!
@IBOutlet weak var leadEdgeSlider: NSSlider!
@IBOutlet weak var initialTailEdgeSlider: NSSlider!
@IBOutlet weak var tailEdgeSlider: NSSlider!
@IBOutlet weak var soundGapSlider: NSSlider!
// @IBOutlet weak var soundGap: NSTextFieldCell!
//
// @IBAction func SoundGapChanged(_ sender: NSStepper) {
// SoundGap.integerValue = sender.integerValue
// spkr_extra_buf = Int32( sender.integerValue )
// }
@IBAction func CRTMonitorOnOff(_ sender: NSButton) {
CRTMonitor = sender.state == .on

View File

@@ -61,7 +61,7 @@ extern float SPKR_INITIAL_LEADING_EDGE; // leading edge should be pretty steep t
extern float SPKR_INITIAL_TRAILING_EDGE; // need a bit of slope to get Xonix sound good
#define SPKR_SAMPLE_PWM_THRESHOLD 12 // to detect PWM controlled speaker control like in Wavy Navy or Xonix
#define SPKR_SAMPLE_PWM_THRESHOLD 8 // to detect PWM controlled speaker control like in Wavy Navy or Xonix