add sound capability to vsrc
see https://sourceforge.net/p/ngspice/patches/13/
This commit is contained in:
parent
df6ba94ee6
commit
1c3fefa1f3
|
|
@ -23,6 +23,8 @@ IFparm VSRCpTable[] = { /* parameters */
|
|||
IOP ("am", VSRC_AM, IF_REALVEC,"Amplitude modulation description"),
|
||||
IOP ("trnoise", VSRC_TRNOISE, IF_REALVEC,"Transient noise description"),
|
||||
IOP ("trrandom", VSRC_TRRANDOM, IF_REALVEC,"random source description"),
|
||||
IP ("snd", VSRC_SOUND, IF_REALVEC,"External sound source parameters"),
|
||||
OPU ("file", VSRC_FILE, IF_STRING, "External sound source filename"),
|
||||
#ifdef SHARED_MODULE
|
||||
IOP ("external", VSRC_EXTERNAL, IF_STRING,"external source description"),
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -322,6 +322,11 @@ VSRCaccept(CKTcircuit *ckt, GENmodel *inModel)
|
|||
}
|
||||
break;
|
||||
|
||||
case SOUND: {
|
||||
/* no breakpoints (yet) */
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef SHARED_MODULE
|
||||
case EXTERNAL: {
|
||||
/* no breakpoints (yet) */
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ VSRCask(CKTcircuit *ckt, GENinstance *inst, int which, IFvalue *value, IFvalue *
|
|||
case VSRC_AM:
|
||||
case VSRC_TRNOISE:
|
||||
case VSRC_TRRANDOM:
|
||||
case VSRC_SOUND:
|
||||
case VSRC_FCN_COEFFS:
|
||||
temp = value->v.numValue = here->VSRCfunctionOrder;
|
||||
v = value->v.vec.rVec = TMALLOC(double, here->VSRCfunctionOrder);
|
||||
|
|
|
|||
|
|
@ -154,7 +154,8 @@ enum {
|
|||
AM,
|
||||
TRNOISE,
|
||||
TRRANDOM,
|
||||
EXTERNAL
|
||||
EXTERNAL,
|
||||
SOUND
|
||||
#ifdef RFSPICE
|
||||
,
|
||||
PORT
|
||||
|
|
@ -199,6 +200,8 @@ enum {
|
|||
VSRC_TRNOISE,
|
||||
VSRC_TRRANDOM,
|
||||
VSRC_EXTERNAL,
|
||||
VSRC_SOUND,
|
||||
VSRC_FILE,
|
||||
};
|
||||
|
||||
/* model parameters */
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ Modified: 2000 AlansFixes
|
|||
#include "ngspice/suffix.h"
|
||||
#include "ngspice/1-f-code.h"
|
||||
#include "ngspice/compatmode.h"
|
||||
#include "vsjack.h"
|
||||
|
||||
#ifdef XSPICE_EXP
|
||||
/* gtri - begin - wbk - modify for supply ramping option */
|
||||
|
|
@ -423,6 +424,12 @@ VNoi3 3 0 DC 0 TRNOISE(0 0 0 0 15m 22u 50u) : generate RTS noise
|
|||
}
|
||||
break;
|
||||
|
||||
case SOUND: {
|
||||
value = here->VSRCcoeffs[2] * vsjack_get_value((int)here->VSRCcoeffs[0], time, here->VSRCcoeffs[3], (int)rint(here->VSRCcoeffs[4]), rint(here->VSRCcoeffs[5]));
|
||||
value += here->VSRCcoeffs[1];
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef SHARED_MODULE
|
||||
case EXTERNAL: {
|
||||
value = getvsrcval(time, here->VSRCname);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ Modified: 2000 AlansFixes
|
|||
#include "ngspice/sperror.h"
|
||||
#include "ngspice/suffix.h"
|
||||
#include "ngspice/1-f-code.h"
|
||||
#include "vsjack.h"
|
||||
|
||||
|
||||
|
||||
static void copy_coeffs(VSRCinstance *here, IFvalue *value)
|
||||
|
|
@ -34,6 +36,8 @@ int
|
|||
VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
||||
{
|
||||
int i;
|
||||
static char* jfile = NULL;
|
||||
|
||||
VSRCinstance *here = (VSRCinstance *) inst;
|
||||
|
||||
NG_IGNORE(select);
|
||||
|
|
@ -285,6 +289,27 @@ VSRCparam(int param, IFvalue *value, GENinstance *inst, IFvalue *select)
|
|||
}
|
||||
break;
|
||||
|
||||
case VSRC_FILE: {
|
||||
jfile = strdup(value->sValue);
|
||||
}
|
||||
break;
|
||||
|
||||
case VSRC_SOUND: {
|
||||
here->VSRCfunctionType = SOUND;
|
||||
here->VSRCfuncTGiven = TRUE;
|
||||
here->VSRCcoeffs = value->v.vec.rVec;
|
||||
here->VSRCcoeffsGiven = TRUE;
|
||||
vsjack_open(-1); // initialize
|
||||
if (jfile) {
|
||||
vsjack_set_file((int)rint(here->VSRCcoeffs[0]), jfile);
|
||||
tfree(jfile);
|
||||
}
|
||||
if (value->v.numValue != 6)
|
||||
fprintf(stderr, "Warning! invalid jack args: %i\nFormat: jack(id v_off v_mult t_off channel oversampling)", value->v.numValue);
|
||||
vsjack_open((int)rint(here->VSRCcoeffs[0]));
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef SHARED_MODULE
|
||||
case VSRC_EXTERNAL: {
|
||||
here->VSRCfunctionType = EXTERNAL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue