diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/action.c | 2 | ||||
-rw-r--r-- | apps/pcmbuf.c | 27 | ||||
-rw-r--r-- | apps/playback.c | 4 |
3 files changed, 15 insertions, 18 deletions
diff --git a/apps/action.c b/apps/action.c index 5ceeeb896f..5f845ab272 100644 --- a/apps/action.c +++ b/apps/action.c | |||
@@ -130,7 +130,7 @@ static int get_action_worker(int context, int timeout, | |||
130 | /* Produce keyclick */ | 130 | /* Produce keyclick */ |
131 | if (global_settings.keyclick && !(button & BUTTON_REL)) | 131 | if (global_settings.keyclick && !(button & BUTTON_REL)) |
132 | if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats) | 132 | if (!(button & BUTTON_REPEAT) || global_settings.keyclick_repeats) |
133 | pcmbuf_beep(5000, 2, 2500*global_settings.keyclick); | 133 | pcmbuf_beep(4000, 2, 2500*global_settings.keyclick); |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | if ((context != last_context) && ((last_button & BUTTON_REL) == 0)) | 136 | if ((context != last_context) && ((last_button & BUTTON_REL) == 0)) |
diff --git a/apps/pcmbuf.c b/apps/pcmbuf.c index 61c6c45de2..c7db4d3101 100644 --- a/apps/pcmbuf.c +++ b/apps/pcmbuf.c | |||
@@ -954,14 +954,15 @@ bool pcmbuf_insert_buffer(char *buf, int count) | |||
954 | } | 954 | } |
955 | #endif | 955 | #endif |
956 | 956 | ||
957 | #ifndef HAVE_HARDWARE_BEEP | ||
957 | /* Generates a constant square wave sound with a given frequency | 958 | /* Generates a constant square wave sound with a given frequency |
958 | in Hertz for a duration in milliseconds. */ | 959 | in Hertz for a duration in milliseconds. */ |
959 | void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude) | 960 | void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude) |
960 | { | 961 | { |
961 | unsigned int count = 0; | 962 | int i; |
962 | unsigned int i; | 963 | unsigned int step = 0xffffffffu / NATIVE_FREQUENCY * frequency; |
963 | unsigned int interval = NATIVE_FREQUENCY / frequency; | 964 | int32_t phase = 0; |
964 | unsigned int samples = NATIVE_FREQUENCY / 1000 * duration; | 965 | int samples = NATIVE_FREQUENCY / 1000 * duration; |
965 | int32_t sample; | 966 | int32_t sample; |
966 | int16_t *bufstart; | 967 | int16_t *bufstart; |
967 | int16_t *bufptr; | 968 | int16_t *bufptr; |
@@ -986,21 +987,17 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude) | |||
986 | bufptr = bufstart; | 987 | bufptr = bufstart; |
987 | for (i = 0; i < samples; ++i) | 988 | for (i = 0; i < samples; ++i) |
988 | { | 989 | { |
990 | int32_t amp = (phase >> 31) ^ (int32_t)amplitude; | ||
989 | sample = mix ? *bufptr : 0; | 991 | sample = mix ? *bufptr : 0; |
990 | *bufptr++ = clip_sample_16(sample + amplitude); | 992 | *bufptr++ = clip_sample_16(sample + amp); |
991 | if (bufptr > pcmbuf_end) | 993 | if (bufptr >= pcmbuf_end) |
992 | bufptr = (int16_t *)audiobuffer; | 994 | bufptr = (int16_t *)audiobuffer; |
993 | sample = mix ? *bufptr : 0; | 995 | sample = mix ? *bufptr : 0; |
994 | *bufptr++ = clip_sample_16(sample + amplitude); | 996 | *bufptr++ = clip_sample_16(sample + amp); |
995 | if (bufptr > pcmbuf_end) | 997 | if (bufptr >= pcmbuf_end) |
996 | bufptr = (int16_t *)audiobuffer; | 998 | bufptr = (int16_t *)audiobuffer; |
997 | 999 | ||
998 | /* Toggle square wave edge */ | 1000 | phase += step; |
999 | if (++count >= interval) | ||
1000 | { | ||
1001 | count = 0; | ||
1002 | amplitude = -amplitude; | ||
1003 | } | ||
1004 | } | 1001 | } |
1005 | 1002 | ||
1006 | /* Kick off playback if required */ | 1003 | /* Kick off playback if required */ |
@@ -1009,7 +1006,7 @@ void pcmbuf_beep(unsigned int frequency, size_t duration, int amplitude) | |||
1009 | pcm_play_data(NULL, (unsigned char *)bufstart, samples * 4); | 1006 | pcm_play_data(NULL, (unsigned char *)bufstart, samples * 4); |
1010 | } | 1007 | } |
1011 | } | 1008 | } |
1012 | 1009 | #endif /* HAVE_HARDWARE_BEEP */ | |
1013 | 1010 | ||
1014 | /* Returns pcm buffer usage in percents (0 to 100). */ | 1011 | /* Returns pcm buffer usage in percents (0 to 100). */ |
1015 | int pcmbuf_usage(void) | 1012 | int pcmbuf_usage(void) |
diff --git a/apps/playback.c b/apps/playback.c index b21a3c1d46..50c4017200 100644 --- a/apps/playback.c +++ b/apps/playback.c | |||
@@ -694,7 +694,7 @@ static void audio_skip(int direction) | |||
694 | if (playlist_check(ci.new_track + wps_offset + direction)) | 694 | if (playlist_check(ci.new_track + wps_offset + direction)) |
695 | { | 695 | { |
696 | if (global_settings.beep) | 696 | if (global_settings.beep) |
697 | pcmbuf_beep(5000, 100, 2500*global_settings.beep); | 697 | pcmbuf_beep(2000, 100, 2500*global_settings.beep); |
698 | 698 | ||
699 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", direction); | 699 | LOGFQUEUE("audio > audio Q_AUDIO_SKIP %d", direction); |
700 | queue_post(&audio_queue, Q_AUDIO_SKIP, direction); | 700 | queue_post(&audio_queue, Q_AUDIO_SKIP, direction); |
@@ -706,7 +706,7 @@ static void audio_skip(int direction) | |||
706 | { | 706 | { |
707 | /* No more tracks. */ | 707 | /* No more tracks. */ |
708 | if (global_settings.beep) | 708 | if (global_settings.beep) |
709 | pcmbuf_beep(1000, 100, 1000*global_settings.beep); | 709 | pcmbuf_beep(1000, 100, 1500*global_settings.beep); |
710 | } | 710 | } |
711 | } | 711 | } |
712 | 712 | ||