Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Util/Clooper
diff options
context:
space:
mode:
authorJames <james@mackie.(none)>2007-06-27 21:57:27 (GMT)
committer James <james@mackie.(none)>2007-06-27 21:57:27 (GMT)
commit18f125431f3e9c652dc89ab455ad7a249445694f (patch)
treed5b11132cb4352b98695d64de7c935d9c3921f1f /Util/Clooper
parent28070ba58978503c92a703646be76081edf97f43 (diff)
no big improvement
Diffstat (limited to 'Util/Clooper')
-rw-r--r--Util/Clooper/aclient.cpp4
-rw-r--r--Util/Clooper/audio.cpp80
2 files changed, 62 insertions, 22 deletions
diff --git a/Util/Clooper/aclient.cpp b/Util/Clooper/aclient.cpp
index 349250a..187a65e 100644
--- a/Util/Clooper/aclient.cpp
+++ b/Util/Clooper/aclient.cpp
@@ -147,6 +147,7 @@ struct SystemStuff
SystemStuff() : pcm(NULL), period_size(0), rate(0)
{
+ assert(!"deprecated");
}
~SystemStuff()
{
@@ -604,6 +605,7 @@ struct TamTamSound
{
if (sys_stuff->period_size == csound_nframes )
{
+ if (0 > sys_stuff->readbuf((char*)csoundGetInputBuffer(csound))) break;
if (csoundPerformBuffer(csound)) break;
if (0 > sys_stuff->writebuf((char*)csoundGetOutputBuffer(csound))) break;
}
@@ -616,7 +618,7 @@ struct TamTamSound
if (cbuf_pos == csound_nframes)
{
cbuf_pos = 0;
- if (csoundPerformBuffer(csound)) {messed = 1;break;}
+ if (csoundPerformBuffer(csound)) { messed = 1;break;}
cbuf = csoundGetOutputBuffer(csound);
}
upbuf[2*up_pos+0] = cbuf[cbuf_pos*2+0];
diff --git a/Util/Clooper/audio.cpp b/Util/Clooper/audio.cpp
index bd81521..838bc52 100644
--- a/Util/Clooper/audio.cpp
+++ b/Util/Clooper/audio.cpp
@@ -50,19 +50,12 @@ struct AlsaStuff
FILE * log;
int frame_bytes;
int allow_resample;
+ int streams_linked;
snd_pcm_hw_params_t *pt_params, *ct_params; /* templates with rate, format and channels */
snd_pcm_hw_params_t *p_params, *c_params;
snd_pcm_sw_params_t *p_swparams, *c_swparams;
- void link()
- {
- }
- void unlink()
- {
- assert(!"not impl");
- }
-
AlsaStuff( const char * pdev, const char * cdev, snd_pcm_format_t fmt, int chnl, int r0, int p0, int upsample_max, FILE * logfile)
: good_to_go(false),
pdevice(pdev),
@@ -77,7 +70,6 @@ struct AlsaStuff
frame_bytes((snd_pcm_format_width(format) / 8) * channels),
allow_resample(0)
{
-
int err;
snd_pcm_uframes_t p_size, c_size, p_psize, c_psize;
unsigned int p_time, c_time;
@@ -171,17 +163,12 @@ struct AlsaStuff
if (upsample == upsample_max) return;
- if ((err = snd_pcm_link(chandle, phandle)) < 0) {
- printf("Streams link error: %s\n", snd_strerror(err));
- //no big deal...
- }
-
if ((err = snd_pcm_prepare(phandle)) < 0) {
- printf("Prepare error: %s\n", snd_strerror(err));
+ printf("Prepare playback error: %s\n", snd_strerror(err));
return;
}
if ((err = snd_pcm_prepare(chandle)) < 0) {
- printf("Prepare error: %s\n", snd_strerror(err));
+ printf("Prepare capture error: %s\n", snd_strerror(err));
return;
}
good_to_go = true;
@@ -200,13 +187,13 @@ struct AlsaStuff
good_to_go=false;
}
free(silence);
- if ((err = snd_pcm_start(phandle)) < 0) {
- fprintf(log, "Go error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_start(chandle)) < 0) {
+ fprintf(log, "Go capture error: %s\n", snd_strerror(err));
good_to_go=false;
return;
}
- if ((err = snd_pcm_start(chandle)) < 0) {
- fprintf(log, "Go error: %s\n", snd_strerror(err));
+ if ((err = snd_pcm_start(phandle)) < 0) {
+ fprintf(log, "Go playback error: %s\n", snd_strerror(err));
good_to_go=false;
return;
}
@@ -215,7 +202,6 @@ struct AlsaStuff
{
snd_pcm_drop(chandle);
snd_pcm_drain(phandle);
- snd_pcm_unlink(chandle);
snd_pcm_hw_free(phandle);
snd_pcm_hw_free(chandle);
snd_pcm_close(phandle);
@@ -243,10 +229,12 @@ struct AlsaStuff
long frames = period_size;
while( frames )
{
+ fprintf(stderr, "reading a buf\n");
long r = snd_pcm_readi(chandle, buf, frames);
if (r < 0) return r;
buf += r * frame_bytes;
frames -= r;
+ fprintf(stderr, "... done\n");
}
return 0;
}
@@ -388,6 +376,56 @@ struct AlsaStuff
}
};
+typedef char frame_t;
+struct Upsampler
+{
+ AlsaStuff * dev;
+ int ratio;
+ int blocklen;
+
+ frame_t * rbuf;
+ frame_t * wbuf;
+ frame_t * rptr;
+ frame_t * wptr;
+
+ Upsampler( AlsaStuff * dev, int ratio, int blocklen )
+ : dev(dev),
+ ratio(ratio),
+ blocklen(blocklen),
+ rbuf( new frame_t[dev->period_size * dev->frame_bytes ]),
+ wbuf( new frame_t[dev->period_size * dev->frame_bytes ]),
+ rptr(rbuf),
+ wptr(wbuf)
+ {
+ }
+ ~Upsampler()
+ {
+ delete[] rbuf;
+ delete[] wbuf;
+ }
+ //store blocklen * dev->frame_bytes in framebuf
+ long readbuf(frame_t * framebuf)
+ {
+ if ((ratio == 1) && (blocklen == dev->period_size))
+ {
+ }
+ else
+ {
+ }
+ return 0;
+ }
+ //write blocklen * dev->frame_bytes in framebuf
+ long writebuf(const frame_t * __restrict__ framebuf)
+ {
+ if ((ratio == 1) && (blocklen == dev->period_size))
+ {
+ }
+ else
+ {
+ }
+ return 0;
+ }
+};