Mary wrote:
Sisyphus wrote:
----- Original Message -----
From: "Mary" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, September 10, 2008 7:38 AM
Subject: Audio::Data
Hello everybody,
I hope I am posting on the right list.
Cygwin list is probably more appropriate for this problem - I see you've
also posted there, anyway :-)
I am trying to run a program
called rsynth which needs
the Audio::Data module and I have not been able to install it with
MCPAN. The
package is found but the compilation fails:
CPAN.pm: Going to build N/NI/NI-S/Audio-1.029.tar.gz
Checking if your kit is complete...
Looks good
Writing Makefile for Audio::Data
ERROR from evaluation of
/home/Mary/.cpan/build/Audio-1.029-vjksgS/Play/Makefile.PL: Cannot open
config/dummy.xs:No such file or directory at ./Makefile.PL line 54.
In Play/Makefile.PL, the variable $driver is initially set to 'dummy'
- and
then changed depending upon the operating system that is detected. But
there's no test to detect Cygwin, so the variable stays set to 'dummy' -
which is apparently not what you want. I don't know how to fix this
problem.
Maybe in PLay/Makefile.PL you could set $driver to 'win32' and see
how that
goes. README.porting (in the source distro) has this to say:
----------------------------------------------
To add/fix drivers look at Play/Makefile.PL to see how the
architecture specific sub-class is built.
Then edit Play/config/* and re-run Makefile.PL
Only Play/config/sun* have been tested
Play/config/next* have been fully converted
Rest of Play/config/* are really .c files from rsynth-2.0 and
need coberting to true .xs files.
----------------------------------------------
And that's about all I could find. Looks like you'll need to build by
hand
(Perl Makefile.PL, make test, make install) rather than use the
automated
CPAN.pm procedure.
It wouldn't build for me on native Win32. During the 'make' stage I got:
-----------------------------------------------
../config/mmsystem.h:64: error: redefinition of `struct waveformat_tag'
../config/mmsystem.h:73: error: redefinition of `struct
pcmwaveformat_tag'
../config/mmsystem.h:79: error: redefinition of `struct tagWAVEOUTCAPSA'
../config/mmsystem.h:92: error: redefinition of `struct tagWAVEOUTCAPSW'
../config/mmsystem.h:122: error: redefinition of `struct tWAVEFORMATEX'
../config/mmsystem.h:137: error: redefinition of `struct mmtime_tag'
-----------------------------------------------
Cheers,
Rob
Thank you for your answer. This took it a step further.
I also got redefinition errors, which I tried to solve by commenting
out #include <perl.h> in AudioIO.c
(They were not the same redefition errors than yours).
But it still won't compile: (Any suggestion very welcome)
I'm re-sending because I got an very stupid feed back (not from anyone
on this list):
[EMAIL PROTECTED] wrote:
-------------------------------------------------------------------
MDaemon has detected restricted attachments within an email message
-------------------------------------------------------------------
>From : [EMAIL PROTECTED]
To : [EMAIL PROTECTED]
Subject : Re: Audio::Data
Message-ID: <[EMAIL PROTECTED]>
---------------------
Attachment(s) removed
---------------------
AudioIO.c
Audio.h
Sorry about that. I don't know who's the paranoiac bastard who set this
up. I'll try renaming the files to .txt.
Mary
$ make test
make[1]: Entering directory
`/home/Mary/.cpan/build/Audio-1.029-qcTkfH/Data'
gcc -c -DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -fno-strict-aliasing
-pipe -I/usr/local/include -DUSEIMPORTLIB -O3 -DVERSION=\"1.029\"
-DXS_VERSION=\"1.029\" "-I/usr/lib/perl5/5.10/i686-cygwin/CORE"
AudioIO.c
In file included from AudioIO.c:4:
Audio.h:5: error: parse error before "UV"
Audio.h:5: warning: no semicolon at end of struct or union
Audio.h:6: warning: data definition has no type or storage class
Audio.h:7: error: parse error before '*' token
Audio.h:7: warning: data definition has no type or storage class
Audio.h:8: error: parse error before '*' token
Audio.h:8: warning: data definition has no type or storage class
Audio.h:9: error: parse error before '}' token
Audio.h:9: warning: data definition has no type or storage class
Audio.h:36: error: parse error before "_"
Audio.h:41: error: parse error before "_"
Audio.h:42: error: parse error before "_"
Audio.h:43: error: parse error before "_"
Audio.h:44: error: parse error before "_"
Audio.h:45: error: parse error before '*' token
Audio.h:46: error: parse error before "_"
Audio.h:47: error: parse error before "_"
Audio.h:48: error: parse error before "_"
Audio.h:49: error: parse error before "_"
Audio.h:50: error: parse error before "_"
Audio.h:51: error: parse error before "_"
Audio.h:52: error: parse error before "_"
Audio.h:53: error: parse error before "_"
Audio.h:54: error: parse error before "_"
Audio.h:55: error: parse error before "_"
Audio.h:56: error: parse error before "_"
Audio.h:59: error: parse error before "_"
Audio.h:60: error: parse error before "_"
Audio.h:61: error: parse error before "Audio_rate"
AudioIO.c:14: error: parse error before '*' token
AudioIO.c: In function `wblong':
AudioIO.c:19: error: `x' undeclared (first use in this function)
AudioIO.c:19: error: (Each undeclared identifier is reported only once
AudioIO.c:19: error: for each function it appears in.)
AudioIO.c:20: error: `f' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:25: error: parse error before '*' token
AudioIO.c: In function `rblong':
AudioIO.c:29: error: `n' undeclared (first use in this function)
AudioIO.c:31: error: `f' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:38: error: parse error before '*' token
AudioIO.c: In function `Audio_header':
AudioIO.c:42: warning: assignment from incompatible pointer type
AudioIO.c:43: error: `f' undeclared (first use in this function)
AudioIO.c:44: warning: passing arg 1 of `strlen' from incompatible
pointer type
AudioIO.c:45: error: `size' undeclared (first use in this function)
AudioIO.c:46: error: `enc' undeclared (first use in this function)
AudioIO.c:47: error: `rate' undeclared (first use in this function)
AudioIO.c:49: warning: passing arg 1 of `strlen' from incompatible
pointer type
AudioIO.c: At top level:
AudioIO.c:52: error: parse error before '*' token
AudioIO.c: In function `Audio_write':
AudioIO.c:55: error: `n' undeclared (first use in this function)
AudioIO.c:57: error: `au_encoding' undeclared (first use in this
function)
AudioIO.c:66: error: `f' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:99: error: parse error before '*' token
AudioIO.c: In function `Audio_term':
AudioIO.c:101: error: `off_t' undeclared (first use in this function)
AudioIO.c:101: error: parse error before "here"
AudioIO.c:102: error: `f' undeclared (first use in this function)
AudioIO.c:103: error: `here' undeclared (first use in this function)
AudioIO.c:110: error: `SEEK_SET' undeclared (first use in this function)
AudioIO.c:112: error: `au_size' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:118: error: parse error before '*' token
AudioIO.c:118: error: parse error before ')' token
AudioIO.c:129: error: `f' undeclared here (not in a function)
AudioIO.c:129: error: `dsize' undeclared here (not in a function)
AudioIO.c:129: error: initializer element is not constant
AudioIO.c:130: error: `len' undeclared here (not in a function)
AudioIO.c:131: error: parse error before "if"
AudioIO.c:136: warning: parameter names (without types) in function
declaration
AudioIO.c:136: error: function `SvCUR' is initialized like a variable
AudioIO.c:136: warning: data definition has no type or storage class
AudioIO.c:137: error: parse error before '-=' token
AudioIO.c:142: error: parse error before '*' token
AudioIO.c: In function `sun_load':
AudioIO.c:144: error: `STRLEN' undeclared (first use in this function)
AudioIO.c:144: error: parse error before "hdrsz"
AudioIO.c:149: error: `magic' undeclared (first use in this function)
AudioIO.c:150: error: `au' undeclared (first use in this function)
AudioIO.c:151: error: `hdrsz' undeclared (first use in this function)
AudioIO.c:158: error: `SVt_PV' undeclared (first use in this function)
AudioIO.c:165: error: `ulaw2float' undeclared (first use in this
function)
AudioIO.c:168: error: `NULL' undeclared (first use in this function)
AudioIO.c:182: error: `UV' undeclared (first use in this function)
AudioIO.c:182: error: parse error before "samples"
AudioIO.c:183: error: `samples' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:209: error: parse error before '*' token
AudioIO.c: In function `Audio_Load':
AudioIO.c:216: error: `au' undeclared (first use in this function)
AudioIO.c: At top level:
AudioIO.c:225: error: parse error before '*' token
AudioIO.c: In function `Audio_Save':
AudioIO.c:228: error: `au' undeclared (first use in this function)
AudioIO.c:234: error: `STRLEN' undeclared (first use in this function)
AudioIO.c:234: error: parse error before "len"
AudioIO.c:235: warning: assignment makes pointer from integer without
a cast
make[1]: *** [AudioIO.o] Error 1
make[1]: Leaving directory
`/home/Mary/.cpan/build/Audio-1.029-qcTkfH/Data'
make: *** [subdirs] Error 2
Vinsamlega athugið að upplýsingar í tölvupósti þessum og viðhengi eru eingöngu
ætlaðar þeim sem póstinum er beint til og gætu innihaldið upplýsingar sem eru
trúnaðarmál. Sjá nánar: http://www.ru.is/trunadur
Please note that this e-mail and attachments are intended for the named
addresses only and may contain information that is confidential and privileged.
Further information:
http://www.ru.is/trunadur
#define PERL_NO_GET_CONTEXT
#include <EXTERN.h>
//#include <perl.h>
#include "Audio.h"
#define SUN_MAGIC 0x2e736e64 /* Really '.snd' */
#define SUN_HDRSIZE 24 /* Size of minimal header */
#define SUN_UNSPEC ((unsigned)(~0)) /* Unspecified data size */
#define SUN_ULAW 1 /* u-law encoding */
#define SUN_LIN_8 2 /* Linear 8 bits */
#define SUN_LIN_16 3 /* Linear 16 bits */
static void
wblong(pTHX_ PerlIO *f, long x)
{
int i;
for (i = 24; i >= 0; i -= 8)
{
char byte = (char) ((x >> i) & 0xFF);
PerlIO_write(f, &byte, 1);
}
}
static long
rblong(pTHX_ PerlIO *f,int n)
{
long x = 0;
int i;
for (i=0; i < n; i++)
{
long b = PerlIO_getc(f);
x = (x << 8) + (b & 0xFF);
}
return x;
}
void
Audio_header(pTHX_ PerlIO *f,unsigned enc,unsigned rate,
unsigned size,char *comment)
{
if (!comment)
comment = "";
wblong(aTHX_ f, SUN_MAGIC);
wblong(aTHX_ f, SUN_HDRSIZE + strlen(comment));
wblong(aTHX_ f, size);
wblong(aTHX_ f, enc);
wblong(aTHX_ f, rate);
wblong(aTHX_ f, 1); /* channels */
PerlIO_write(f, comment, strlen(comment));
}
static long Audio_write (pTHX_ PerlIO *f, int au_encoding, int n,float *data)
{
long au_size = 0;
if (n > 0)
{
if (au_encoding == SUN_LIN_16)
{
while (n--)
{
short s = float2linear(*data++,16);
/* Write big-endian to match header code */
char b[2];
b[0] = (s >> 8) & 0xFF;
b[1] = (s >> 0) & 0xFF;
if (PerlIO_write(f, b, 2) != 2)
break;
au_size += sizeof(s);
}
}
else if (au_encoding == SUN_ULAW)
{
while (n--)
{
char s = float2ulaw(*data++);
if (PerlIO_write(f, &s, sizeof(s)) != sizeof(s))
break;
au_size += sizeof(s);
}
}
else if (au_encoding == SUN_LIN_8)
{
while (n--)
{
char s = float2linear(*data++,8);
if (PerlIO_write(f, &s, sizeof(s)) != sizeof(s))
break;
au_size += sizeof(s);
}
}
else
{
croak("Unknown format");
}
}
return au_size;
}
static void Audio_term (pTHX_ PerlIO *f,long au_size)
{
off_t here = PerlIO_tell(f);
PerlIO_flush(f);
if (here >= 0)
{
/* can seek this file - truncate it */
#ifndef WIN32
ftruncate(PerlIO_fileno(f), here);
#endif
/* Now go back and overwite header with actual size */
if (PerlIO_seek(f, 8L, SEEK_SET) == 8)
{
wblong(aTHX_ f, au_size);
}
}
}
static void
Audio_read(pTHX_ Audio *au, PerlIO *f,size_t dsize,long count,float
(*proc)(long))
{
SV *data = au->data;
if (count > 0)
{
/* If we know how big it is to be get grow out of the way */
SvGROW(data,SvCUR(data)+(count/dsize)*sizeof(float));
}
while (count && !PerlIO_eof(f))
{
STRLEN len = SvCUR(data);
long v = rblong(aTHX_ f,dsize);
float *p = (float *) (SvGROW(data,len+sizeof(float))+len);
if (proc)
*p = (*proc)(v);
else
*p = linear2float(v, dsize*8);
len += sizeof(float);
SvCUR(data) = len;
count -= dsize;
}
}
static void
sun_load(pTHX_ Audio *au, PerlIO *f, long magic)
{
STRLEN hdrsz = rblong(aTHX_ f,sizeof(long));
long size = rblong(aTHX_ f,sizeof(long));
long enc = rblong(aTHX_ f,sizeof(long));
long rate = rblong(aTHX_ f,sizeof(long));
unsigned chan = rblong(aTHX_ f,sizeof(long));
assert(magic == SUN_MAGIC);
au->rate = rate;
hdrsz -= SUN_HDRSIZE;
if (!au->data)
au->data = newSVpv("",0);
if (hdrsz)
{
if (!au->comment)
au->comment = newSVpv("",0);
sv_upgrade(au->comment,SVt_PV);
PerlIO_read(f,SvGROW(au->comment,hdrsz),hdrsz);
SvCUR(au->comment) = hdrsz;
}
switch(enc)
{
case SUN_ULAW:
Audio_read(aTHX_ au,f,1,size,ulaw2float);
break;
case SUN_LIN_16:
Audio_read(aTHX_ au,f,2,size,NULL);
break;
case SUN_LIN_8:
Audio_read(aTHX_ au,f,1,size,NULL);
break;
default:
croak("Unsupported au format");
break;
}
/* For now we can only represent one channel so average all channels */
if (chan > 1)
{
float *s = AUDIO_DATA(au);
float *d = s;
UV samples = Audio_samples(au);
float *e = s+samples;
if (samples % chan)
{
warn("%d channels but %lu samples",chan,samples);
samples = (samples/chan)*chan;
e = s+samples;
}
while (s < e)
{
unsigned i;
float v = *s++;
for (i = 1; i < chan; i++)
{
v += *s++;
}
*d++ = v / chan;
}
SvCUR_set(au->data,(d-AUDIO_DATA(au))*sizeof(float));
if (!au->comment)
au->comment = newSVpv("",0);
sv_upgrade(au->comment,SVt_PV);
sv_catpvf(au->comment,"averaged from %u channels",chan);
}
}
void
Audio_Load(Audio *au, InputStream f)
{
dTHX;
long magic = rblong(aTHX_ f,sizeof(long));
switch(magic)
{
case SUN_MAGIC:
sun_load(aTHX_ au, f, magic);
break;
default:
croak("Unknown file format");
break;
}
}
void
Audio_Save(Audio *au, OutputStream f, char *comment)
{
dTHX;
long encoding = (au->rate == 8000) ? SUN_ULAW : SUN_LIN_16;
long bytes = Audio_samples(au);
if (encoding != SUN_ULAW)
bytes *= 2;
if (!comment && au->comment && SvOK(au->comment))
{
STRLEN len;
comment = SvPV(au->comment,len);
}
Audio_header(aTHX_ f, encoding, au->rate, bytes, comment);
bytes = Audio_write(aTHX_ f, encoding, Audio_samples(au), (float *)
SvPVX(au->data));
Audio_term(aTHX_ f, bytes);
}
#ifndef _AUDIO
#define _AUDIO
typedef struct
{
UV rate;
IV flags;
SV *comment;
SV *data;
} Audio;
#define AUDIO_F_COMPLEX 1
#define AUDIO_F_FREQ 2
#define AUDIO_COMPLEX(au) ((au)->flags & AUDIO_F_COMPLEX)
#define AUDIO_WORDS(au) (AUDIO_COMPLEX(au) ? 2 : 1)
typedef void fft_f(int n,float *data);
#ifndef dTHX
#define dTHX extern int Audio__notUsed
#define aTHX_
#define pTHX_
#endif
#define InputStream PerlIO *
#define OutputStream PerlIO *
#ifndef AUDIO_PI
#define AUDIO_PI 3.14159265358979323846
#endif
#define Audio_samples(au) (SvCUR((au)->data)/(sizeof(float)*AUDIO_WORDS(au)))
#define Audio_duration(au) ((float) Audio_samples(au)/(au)->rate)
#define Audio_silence(au,t) Audio_more(aTHX_ au,(int) (t*(au)->rate))
#define AUDIO_DATA(au) ((float *) SvPVX((au)->data))
extern float *Audio_more _((pTHX_ Audio *au, int n));
extern short *_u2l; /* 8-bit u-law to 16-bit PCM */
extern unsigned char *_l2u; /* 13-bit PCM to 8-bit u-law */
#define ulaw2short(X) (_u2l[(unsigned char) (X)])
#define short2ulaw(X) (_l2u[((short)(X)) >> 3])
extern long float2ulaw _((float f));
extern float ulaw2float _((long u));
extern long float2linear _((float f,int bits));
extern float linear2float _((long l,int bits));
extern SV * Audio_shorts _((Audio *au));
extern float *Audio_w _((int n));
extern void Audio_r2_fft _((int n,float *data));
extern void Audio_r2_ifft _((int n,float *data));
extern void Audio_r4_fft _((int n,float *data));
extern void Audio_r4_ifft _((int n,float *data));
extern void Audio_conjugate _((int n,float *data,float scale));
extern void Audio_complex_debug _((int N,float *x,PerlIO *f));
extern void Audio_difference _((int n, float *a, float *b));
extern void Audio_autocorrelation _((int N, float *x,unsigned p,float *r));
extern void Audio_durbin _((int NUM_POLES, float *R,float *aa));
extern int Audio_lpc _((int length, const float *sig, int order, float *acf,
float *ref, float *lpc));
extern void Audio_Load _((Audio *au, InputStream f));
extern void Audio_Save _((Audio *au, OutputStream f, char *comment));
extern IV Audio_rate _((Audio * au, IV rate));
#endif /* _AUDIO */
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs