@@ -5,15 +5,14 @@ import (
55 "math"
66
77 "github.com/gotracker/playback/note"
8- per "github.com/gotracker/playback/period"
98 "github.com/heucuva/comparison"
109
11- "github.com/gotracker/voice /period"
10+ "github.com/gotracker/playback /period"
1211)
1312
1413// Amiga defines a sampler period that follows the Amiga-style approach of note
1514// definition. Useful in calculating resampling.
16- type Amiga per .AmigaPeriod
15+ type Amiga period .AmigaPeriod
1716
1817// AddInteger truncates the current period to an integer and adds the delta integer in
1918// then returns the resulting period
@@ -24,17 +23,16 @@ func (p Amiga) AddInteger(delta int) Amiga {
2423
2524// Add adds the current period to a delta value then returns the resulting period
2625func (p Amiga ) AddDelta (delta period.Delta ) period.Period {
27- period := p
28- d := note .ToPeriodDelta (delta )
29- period += Amiga (d )
30- return period
26+ d := period .ToPeriodDelta (delta )
27+ p += Amiga (d )
28+ return p
3129}
3230
3331// Compare returns:
3432// -1 if the current period is higher frequency than the `rhs` period
3533// 0 if the current period is equal in frequency to the `rhs` period
3634// 1 if the current period is lower frequency than the `rhs` period
37- func (p Amiga ) Compare (rhs note .Period ) comparison.Spaceship {
35+ func (p Amiga ) Compare (rhs period .Period ) comparison.Spaceship {
3836 lf := p .GetFrequency ()
3937 rf := rhs .GetFrequency ()
4038
@@ -49,32 +47,32 @@ func (p Amiga) Compare(rhs note.Period) comparison.Spaceship {
4947}
5048
5149// Lerp linear-interpolates the current period with the `rhs` period
52- func (p Amiga ) Lerp (t float64 , rhs note .Period ) note .Period {
50+ func (p Amiga ) Lerp (t float64 , rhs period .Period ) period .Period {
5351 right := Amiga (0 )
5452 if r , ok := rhs .(Amiga ); ok {
5553 right = r
5654 }
5755
58- period := Amiga (per .AmigaPeriod (p ).Lerp (t , per .AmigaPeriod (right )))
56+ period := Amiga (period .AmigaPeriod (p ).Lerp (t , period .AmigaPeriod (right )))
5957 return period
6058}
6159
6260// GetSamplerAdd returns the number of samples to advance an instrument by given the period
6361func (p Amiga ) GetSamplerAdd (samplerSpeed float64 ) float64 {
64- return float64 (per .AmigaPeriod (p ).GetFrequency (period .Frequency (samplerSpeed )))
62+ return float64 (period .AmigaPeriod (p ).GetFrequency (period .Frequency (samplerSpeed )))
6563}
6664
6765// GetFrequency returns the frequency defined by the period
6866func (p Amiga ) GetFrequency () period.Frequency {
69- return per .AmigaPeriod (p ).GetFrequency (period .Frequency (ITBaseClock ))
67+ return period .AmigaPeriod (p ).GetFrequency (period .Frequency (ITBaseClock ))
7068}
7169
7270func (p Amiga ) String () string {
7371 return fmt .Sprintf ("Amiga{ Period:%f }" , float32 (p ))
7472}
7573
7674// ToAmigaPeriod calculates an amiga period for a linear finetune period
77- func ToAmigaPeriod (finetunes note.Finetune , c2spd note. C2SPD ) Amiga {
75+ func ToAmigaPeriod (finetunes note.Finetune , c2spd period. Frequency ) Amiga {
7876 if finetunes < 0 {
7977 finetunes = 0
8078 }
0 commit comments