diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/sound.h | 4 | ||||
-rw-r--r-- | firmware/sound.c | 19 |
2 files changed, 13 insertions, 10 deletions
diff --git a/firmware/export/sound.h b/firmware/export/sound.h index 70c4a2244e..674b2f6ae2 100644 --- a/firmware/export/sound.h +++ b/firmware/export/sound.h | |||
@@ -60,8 +60,8 @@ void sound_set(int setting, int value); | |||
60 | int sound_val2phys(int setting, int value); | 60 | int sound_val2phys(int setting, int value); |
61 | 61 | ||
62 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 62 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
63 | void sound_set_pitch(int permille); | 63 | void sound_set_pitch(int32_t pitch); |
64 | int sound_get_pitch(void); | 64 | int32_t sound_get_pitch(void); |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #endif | 67 | #endif |
diff --git a/firmware/sound.c b/firmware/sound.c index f4a2f87ca5..6a2f03df00 100644 --- a/firmware/sound.c +++ b/firmware/sound.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "sound.h" | 25 | #include "sound.h" |
26 | #include "logf.h" | 26 | #include "logf.h" |
27 | #include "system.h" | 27 | #include "system.h" |
28 | /* for the pitch and speed precision #defines: */ | ||
29 | #include "pitchscreen.h" | ||
28 | #ifndef SIMULATOR | 30 | #ifndef SIMULATOR |
29 | #include "i2c.h" | 31 | #include "i2c.h" |
30 | #include "mas.h" | 32 | #include "mas.h" |
@@ -159,6 +161,7 @@ sound_set_type* sound_get_fn(int setting) | |||
159 | 161 | ||
160 | #if CONFIG_CODEC == SWCODEC | 162 | #if CONFIG_CODEC == SWCODEC |
161 | /* Copied from dsp.h, nasty nasty, but we don't want to include dsp.h */ | 163 | /* Copied from dsp.h, nasty nasty, but we don't want to include dsp.h */ |
164 | |||
162 | enum { | 165 | enum { |
163 | DSP_CALLBACK_SET_PRESCALE = 0, | 166 | DSP_CALLBACK_SET_PRESCALE = 0, |
164 | DSP_CALLBACK_SET_BASS, | 167 | DSP_CALLBACK_SET_BASS, |
@@ -698,18 +701,18 @@ int sound_val2phys(int setting, int value) | |||
698 | crystal frequency than we actually have. It will adjust its internal | 701 | crystal frequency than we actually have. It will adjust its internal |
699 | parameters and the result is that the audio is played at another pitch. | 702 | parameters and the result is that the audio is played at another pitch. |
700 | 703 | ||
701 | The pitch value is in tenths of percent. | 704 | The pitch value precision is based on PITCH_SPEED_PRECISION (in dsp.h) |
702 | */ | 705 | */ |
703 | static int last_pitch = 1000; | 706 | static int last_pitch = PITCH_SPEED_100; |
704 | 707 | ||
705 | void sound_set_pitch(int pitch) | 708 | void sound_set_pitch(int32_t pitch) |
706 | { | 709 | { |
707 | unsigned long val; | 710 | unsigned long val; |
708 | 711 | ||
709 | if (pitch != last_pitch) | 712 | if (pitch != last_pitch) |
710 | { | 713 | { |
711 | /* Calculate the new (bogus) frequency */ | 714 | /* Calculate the new (bogus) frequency */ |
712 | val = 18432 * 1000 / pitch; | 715 | val = 18432 * PITCH_SPEED_100 / pitch; |
713 | 716 | ||
714 | mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1); | 717 | mas_writemem(MAS_BANK_D0, MAS_D0_OFREQ_CONTROL, &val, 1); |
715 | 718 | ||
@@ -721,19 +724,19 @@ void sound_set_pitch(int pitch) | |||
721 | } | 724 | } |
722 | } | 725 | } |
723 | 726 | ||
724 | int sound_get_pitch(void) | 727 | int32_t sound_get_pitch(void) |
725 | { | 728 | { |
726 | return last_pitch; | 729 | return last_pitch; |
727 | } | 730 | } |
728 | #else /* SIMULATOR */ | 731 | #else /* SIMULATOR */ |
729 | void sound_set_pitch(int pitch) | 732 | void sound_set_pitch(int32_t pitch) |
730 | { | 733 | { |
731 | (void)pitch; | 734 | (void)pitch; |
732 | } | 735 | } |
733 | 736 | ||
734 | int sound_get_pitch(void) | 737 | int32_t sound_get_pitch(void) |
735 | { | 738 | { |
736 | return 1000; | 739 | return PITCH_SPEED_100; |
737 | } | 740 | } |
738 | #endif /* SIMULATOR */ | 741 | #endif /* SIMULATOR */ |
739 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ | 742 | #endif /* (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) */ |