summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/rbsound.c
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2007-06-24 16:00:55 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2007-06-24 16:00:55 +0000
commit78c45530fff6100240d08be77858350632000de9 (patch)
tree38d312e754cf87e1ea45ca1faf72fdd2d546fde2 /apps/plugins/rockboy/rbsound.c
parent16ca78db033f86c482cceb25dd1eee32aae2ecfc (diff)
downloadrockbox-78c45530fff6100240d08be77858350632000de9.tar.gz
rockbox-78c45530fff6100240d08be77858350632000de9.zip
Sound improvements for rockboy - players now sync the sound (The gigabeat now plays at a steady 60 fps as long as the frameskip is set properly). If a new sample is not available a blank buffer is used. All devices use 44.1 kHz for gameboy sound now so no more high pitched sounds. Added a screen rotation option. Removed unscaled code for devices with a screensize smaller than the gameboy. All buttons are now configurable. Scroll wheel devices still have button configuration problems though.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13698 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/rbsound.c')
-rw-r--r--apps/plugins/rockboy/rbsound.c64
1 files changed, 16 insertions, 48 deletions
diff --git a/apps/plugins/rockboy/rbsound.c b/apps/plugins/rockboy/rbsound.c
index e671554e25..163c39aa66 100644
--- a/apps/plugins/rockboy/rbsound.c
+++ b/apps/plugins/rockboy/rbsound.c
@@ -5,21 +5,20 @@
5struct pcm pcm IBSS_ATTR; 5struct pcm pcm IBSS_ATTR;
6 6
7#define N_BUFS 2 7#define N_BUFS 2
8#define BUF_SIZE 1024 8#define BUF_SIZE 2048
9
10#if CONFIG_CODEC == SWCODEC && !defined(SIMULATOR)
11 9
12bool doneplay=1; 10bool doneplay=1;
11bool bufnum=0;
13 12
14static unsigned char *buf=0; 13static unsigned short *buf=0;
15static unsigned short *gmbuf;
16 14
17static bool newly_started; 15static bool newly_started;
18 16
19void get_more(unsigned char** start, size_t* size) 17void get_more(unsigned char** start, size_t* size)
20{ 18{
21 *start = (unsigned char*)(&gmbuf[pcm.len*doneplay]); 19 *start = (unsigned char*)(&buf[pcm.len*doneplay]);
22 *size = BUF_SIZE*sizeof(short); 20 *size = BUF_SIZE*sizeof(short);
21 doneplay=1;
23} 22}
24 23
25void pcm_init(void) 24void pcm_init(void)
@@ -29,19 +28,17 @@ void pcm_init(void)
29 28
30 newly_started = true; 29 newly_started = true;
31 30
32 pcm.hz = 11025; 31 pcm.hz = SAMPR_44;
33 pcm.stereo = 1; 32 pcm.stereo = 1;
34 33
35 pcm.len = BUF_SIZE; 34 pcm.len = BUF_SIZE;
36 if(!buf) 35 if(!buf)
37 { 36 {
38 buf = my_malloc(pcm.len * N_BUFS); 37 buf = my_malloc(pcm.len * N_BUFS *sizeof(short));
39 gmbuf = my_malloc(pcm.len * N_BUFS*sizeof (short));
40 38
41 pcm.buf = buf; 39 pcm.buf = buf;
42 pcm.pos = 0; 40 pcm.pos = 0;
43 memset(gmbuf, 0, pcm.len * N_BUFS *sizeof(short)); 41 memset(buf, 0, pcm.len * N_BUFS*sizeof(short));
44 memset(buf, 0, pcm.len * N_BUFS);
45 } 42 }
46 43
47 rb->pcm_play_stop(); 44 rb->pcm_play_stop();
@@ -52,7 +49,7 @@ void pcm_init(void)
52 rb->audio_set_output_source(AUDIO_SRC_PLAYBACK); 49 rb->audio_set_output_source(AUDIO_SRC_PLAYBACK);
53#endif 50#endif
54 51
55 rb->pcm_set_frequency(SAMPR_11); /* 44100 22050 11025 */ 52 rb->pcm_set_frequency(pcm.hz); /* 44100 22050 11025 */
56} 53}
57 54
58void pcm_close(void) 55void pcm_close(void)
@@ -65,50 +62,21 @@ void pcm_close(void)
65 62
66int pcm_submit(void) 63int pcm_submit(void)
67{ 64{
68 register int i; 65 if (!pcm.buf) return 0;
69
70 if (pcm.pos < pcm.len) return 1; 66 if (pcm.pos < pcm.len) return 1;
71 67
72 doneplay=!doneplay;
73
74 if(doneplay)
75 pcm.buf = buf + pcm.len;
76 else
77 pcm.buf = buf;
78
79 pcm.pos = 0;
80
81 /* gotta convert the 8 bit buffer to 16 */
82 for(i=0; i<pcm.len;i++)
83 gmbuf[i+pcm.len*doneplay] = (pcm.buf[i]<<8)-0x8000;
84
85 if(newly_started) 68 if(newly_started)
86 { 69 {
87 rb->pcm_play_data(&get_more,NULL,0); 70 rb->pcm_play_data(&get_more,NULL,0);
88 newly_started = false; 71 newly_started = false;
89 } 72 }
90 73
91 return 1; 74 while (!doneplay)
92} 75 {rb->yield();}
93#else
94static byte buf1_unal[(BUF_SIZE / sizeof(short)) + 2]; /* 4 byte aligned */
95void pcm_init(void)
96{
97 pcm.hz = 11025;
98 pcm.stereo = 1;
99 pcm.buf = buf1_unal;
100 pcm.len = (BUF_SIZE / sizeof(short));
101 pcm.pos = 0;
102}
103 76
104void pcm_close(void) 77 doneplay=0;
105{ 78
106 memset(&pcm, 0, sizeof pcm); 79 pcm.pos = 0;
107} 80 return 1;
108int pcm_submit(void)
109{
110 pcm.pos =0;
111 return 0;
112} 81}
113#endif
114 82