Subversion Repositories svn.mios

Rev

Rev 1102 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1102 Rev 1189
Line 1... Line 1...
1
; $Id: sid_se.inc 1102 2012-12-30 20:39:10Z tk $
1
; $Id: sid_se.inc 1189 2014-12-19 20:00:14Z tk $
2
;
2
;
3
; MIDIbox SID
3
; MIDIbox SID
4
; Software Synthesizer Engine
4
; Software Synthesizer Engine
5
;  
5
;  
6
; Activate this #define to measure the performance with a scope
6
; Activate this #define to measure the performance with a scope
Line 9... Line 9...
9
;
9
;
10
; ==========================================================================
10
; ==========================================================================
11
;
11
;
12
;  Copyright 1998-2007 Thorsten Klose (tk@midibox.org)
12
;  Copyright 1998-2007 Thorsten Klose (tk@midibox.org)
13
;  Idea for ENV Curve Parameter and OSC synchronization by Jess D. Skov-Nielsen
13
;  Idea for ENV Curve Parameter and OSC synchronization by Jess D. Skov-Nielsen
-
 
14
;  SuperSaw detune mode created by Lis0r
14
;  Licensed for personal non-commercial use only.
15
;  Licensed for personal non-commercial use only.
15
;  All other rights reserved.
16
;  All other rights reserved.
16
; 
17
; 
17
; ==========================================================================
18
; ==========================================================================
18
19

Line 1568... Line 1569...
1568
	movf	SID_PATCH_BUFFER_SHADOW + SID_Ix_L_OSC_DETUNE, W, BANKED
1569
	movf	SID_PATCH_BUFFER_SHADOW + SID_Ix_L_OSC_DETUNE, W, BANKED
1569
	SET_BSR	SID_BASE
1570
	SET_BSR	SID_BASE
1570
	bz	SIDSE_Pitch_NoDetune
1571
	bz	SIDSE_Pitch_NoDetune
1571
SIDSE_Pitch_Detune
1572
SIDSE_Pitch_Detune
1572
	movwf	IRQ_TMP1
1573
	movwf	IRQ_TMP1
-
 
1574
-
 
1575
	;; implement detune modes
-
 
1576
	SET_BSR	SID_PATCH_BUFFER_SHADOW
-
 
1577
	BRA_IFSET SID_PATCH_BUFFER_SHADOW + SID_Ix_L_OSC_DTM, 0, BANKED, SIDSE_Pitch_SuperNeg
-
 
1578
	BRA_IFSET SID_PATCH_BUFFER_SHADOW + SID_Ix_L_OSC_DTM, 1, BANKED, SIDSE_Pitch_SuperPos
-
 
1579
	SET_BSR	SID_BASE
-
 
1580
	rgoto SIDSE_Pitch_NormalDetune
-
 
1581
-
 
1582
	;; super-saw like detune modes
-
 
1583
	;; Created by Lis0r, based on the research from this paper:
-
 
1584
	;; http://www.nada.kth.se/utbildning/grukth/exjobb/rapportlistor/2010/rapporter10/szabo_adam_10131.pdf
-
 
1585
SIDSE_Pitch_SuperNeg
-
 
1586
	SET_BSR	SID_BASE
-
 
1587
	;; Left OSC1: -detune
-
 
1588
	BRA_IFSET SID_SE_ELEMENT_NUM, 2, BANKED, SIDSE_Pitch_Super_45
-
 
1589
SIDSE_Pitch_SuperNeg_0123
-
 
1590
	BRA_IFSET SID_SE_ELEMENT_NUM, 1, BANKED, SIDSE_Pitch_Super_23
-
 
1591
SIDSE_Pitch_SuperNeg_01
-
 
1592
	BRA_IFSET SID_SE_ELEMENT_NUM, 0, BANKED, SIDSE_Pitch_Super_1
-
 
1593
SIDSE_Pitch_SuperNeg_0 ; SIDL, OSC1
-
 
1594
	rgoto	SIDSE_Pitch_Detune_Sub
-
 
1595

-
 
1596
SIDSE_Pitch_SuperPos
-
 
1597
	SET_BSR	SID_BASE
-
 
1598
	;; Left OSC1: +detune
-
 
1599
	BRA_IFSET SID_SE_ELEMENT_NUM, 2, BANKED, SIDSE_Pitch_Super_45
-
 
1600
SIDSE_Pitch_SuperPos_0123
-
 
1601
	BRA_IFSET SID_SE_ELEMENT_NUM, 1, BANKED, SIDSE_Pitch_Super_23
-
 
1602
SIDSE_Pitch_SuperPos_01
-
 
1603
	BRA_IFSET SID_SE_ELEMENT_NUM, 0, BANKED, SIDSE_Pitch_Super_1
-
 
1604
SIDSE_Pitch_SuperPos_0 ; SIDL, OSC1
-
 
1605
	rgoto	SIDSE_Pitch_Detune_Add
-
 
1606

-
 
1607
	;; Right OSC1: 0
-
 
1608
	;; Left OSC2: +detune/3
-
 
1609
	;; Right OSC2: -detune/3
-
 
1610
	;; Left OSC3: -2*detune/3
-
 
1611
	;; Right OSC3: +2*detune/3
-
 
1612
SIDSE_Pitch_Super_1 ; SIDL, OSC2
-
 
1613
	rcall	SIDSE_Hlp_Div3
-
 
1614
	rgoto	SIDSE_Pitch_Detune_Add
-
 
1615
	
-
 
1616
SIDSE_Pitch_Super_23
-
 
1617
	BRA_IFSET SID_SE_ELEMENT_NUM, 0, BANKED, SIDSE_Pitch_Super_3
-
 
1618
SIDSE_Pitch_Super_2	; SIDL, OSC3
-
 
1619
	rcall SIDSE_Hlp_Div3
-
 
1620
	movf  IRQ_TMP1, W
-
 
1621
	addwf IRQ_TMP1, F
-
 
1622
	rgoto	SIDSE_Pitch_Detune_Sub
-
 
1623
SIDSE_Pitch_Super_3	; SIDR, OSC1
-
 
1624
	rgoto SIDSE_Pitch_NoDetune
-
 
1625
	
-
 
1626
SIDSE_Pitch_Super_45
-
 
1627
	BRA_IFSET SID_SE_ELEMENT_NUM, 0, BANKED, SIDSE_Pitch_Super_5
-
 
1628
SIDSE_Pitch_Super_4	; SIDR, OSC2
-
 
1629
	rcall SIDSE_Hlp_Div3
-
 
1630
	rgoto	SIDSE_Pitch_Detune_Sub
-
 
1631
SIDSE_Pitch_Super_5	; SIDR, OSC3
-
 
1632
	rcall SIDSE_Hlp_Div3
-
 
1633
	movf  IRQ_TMP1, W
-
 
1634
	addwf IRQ_TMP1, F
-
 
1635
	rgoto	SIDSE_Pitch_Detune_Add
-
 
1636
-
 
1637
	;; traditional normal detune mode
-
 
1638
SIDSE_Pitch_NormalDetune
-
 
1639
	movf	SID_PATCH_BUFFER_SHADOW + SID_Ix_L_OSC_DETUNE, W, BANKED
-
 
1640
	SET_BSR	SID_BASE
-
 
1641
	bz	SIDSE_Pitch_NoDetune
1573
	;; additional detuning depending on SID channel and oscillator
1642
	;; additional detuning depending on SID channel and oscillator
1574
	;; Left OSC1: +detune/4   (lead only, 0 in bassline mode)
1643
	;; Left OSC1: +detune/4   (lead only, 0 in bassline mode)
1575
	;; Right OSC1: -detune/4  (lead only, 0 in bassline mode)
1644
	;; Right OSC1: -detune/4  (lead only, 0 in bassline mode)
1576
	;; Left OSC2: +detune
1645
	;; Left OSC2: +detune
1577
	;; Right OSC2: -detune
1646
	;; Right OSC2: -detune
Line 2793... Line 2862...
2793
;; --------------------------------------------------------------------------
2862
;; --------------------------------------------------------------------------
2794
;; --------------------------------------------------------------------------
2863
;; --------------------------------------------------------------------------
2795
;;  Help Functions which are used by all engines
2864
;;  Help Functions which are used by all engines
2796
;; --------------------------------------------------------------------------
2865
;; --------------------------------------------------------------------------
2797
;; --------------------------------------------------------------------------
2866
;; --------------------------------------------------------------------------
-
 
2867
-
 
2868
;; --------------------------------------------------------------------------
-
 
2869
;; Help Function: Divide by 3 by evaluating series x/2 - x/4 + x/8 - x/16...
-
 
2870
;; based on http://www.piclist.com/techref/microchip/math/div/8byconst3-aw.htm
-
 
2871
;; IN:  8 bit value in IRQ_TMP1
-
 
2872
;; OUT: result in IRQ_TMP1
-
 
2873
;; USES: WREG
-
 
2874
;; --------------------------------------------------------------------------
-
 
2875
SIDSE_Hlp_Div3						
-
 
2876
	movff  IRQ_TMP1, IRQ_TMP2
-
 
2877
 	clrf   IRQ_TMP1
-
 
2878
-
 
2879
SIDSE_Hlp_Div3_Loop			;; while IRQ_TMP2 != 0
-
 
2880
 	bcf    STATUS, C
-
 
2881
 	rrf    IRQ_TMP2, F		;; IRQ_TMP2 /= 2 (i.e. "x/2" in Series)
-
 
2882
 	movf   IRQ_TMP2, W		
-
 
2883
 	btfsc  STATUS, Z		;; ==0?
-
 
2884
 	return					;; Yes, done
-
 
2885

-
 
2886
 	addwf  IRQ_TMP1, F		;; IRQ_TMP1 += IRQ_TMP2
-
 
2887
 	
-
 
2888
	rrf    IRQ_TMP2, F		;; IRQ_TMP2 /= 2 (i.e. "x/4" in Series)
-
 
2889
	movf   IRQ_TMP2, W
-
 
2890
	btfsc  STATUS, Z 		;; ==0?
-
 
2891
	return					;; Yes, done
-
 
2892

-
 
2893
	subwf  IRQ_TMP1, f		;; IRQ_TMP1 -= IRQ_TMP2
-
 
2894
	goto   SIDSE_Hlp_Div3_Loop
2798
2895

2799
;; --------------------------------------------------------------------------
2896
;; --------------------------------------------------------------------------
2800
;; Help Function: Scale Depth (7bit signed value scales 15bit signed value)
2897
;; Help Function: Scale Depth (7bit signed value scales 15bit signed value)
2801
;; IN:  8bit signed depth value (+0x80) in WREG
2898
;; IN:  8bit signed depth value (+0x80) in WREG
2802
;;      15bit signed value in MUL_A_[LH]
2899
;;      15bit signed value in MUL_A_[LH]