Exemplo n.º 1
0
void CCoreAudioDevice::Close()
{
  if (!m_DeviceId)
    return;

  // Stop the device if it was started
  Stop();

  // Unregister the IOProc if we have one
  RemoveIOProc();

  SetHogStatus(false);
  CCoreAudioHardware::SetAutoHogMode(false);

  if (m_MixerRestore > -1) // We changed the mixer status
    SetMixingSupport((m_MixerRestore ? true : false));
  m_MixerRestore = -1;

  if (m_SampleRateRestore != 0.0f)
    SetNominalSampleRate(m_SampleRateRestore);

  if (m_BufferSizeRestore && m_BufferSizeRestore != GetBufferSize())
  {
    SetBufferSize(m_BufferSizeRestore);
    m_BufferSizeRestore = 0;
  }

  m_IoProc = NULL;
  m_DeviceId = 0;
  m_ObjectListenerProc = NULL;
}
Exemplo n.º 2
0
CVWString::CVWString( int str_length )
{
	v_pData = NULL;
	v_nSize = 0;

	SetBufferSize(str_length);
}
Exemplo n.º 3
0
CString &CString::Insert( int i, const char *_str )
{
    if ( str && _str )
    {
		//portENTER_CRITICAL();

        if ( i < 0 ) i = 0;
        else if ( i > length ) i = length;

        int slen = strlen( _str );

        if ( SetBufferSize( length + slen + 1 ) )
        {
            for ( int j = length; j >= i; j-- )
                str[ j + slen ] = str[ j ];

            memcpy( &str[ i ], _str, slen );
            length += slen;
        }
        else length = 0;

		//portEXIT_CRITICAL();
    }

    return *this;
}
Exemplo n.º 4
0
bool DspOscillator::ParameterUpdating_(int index, DspParameter const& param)
{
    if (index == pBufferSize)
    {
        SetBufferSize(*param.GetInt());
        return true;
    }
    else if (index == pSampleRate)
    {
        SetSampleRate(*param.GetInt());
        return true;
    }
    else if (index == pAmplitude)
    {
        SetAmpl(*param.GetFloat());
        return true;
    }
    else if (index == pFrequency)
    {
        SetFreq(*param.GetFloat());
        return true;
    }

    return false;
}
Exemplo n.º 5
0
// initialize buffer coordinates
// parm1=Number of Strings/Arches
// parm2=Pixels Per String/Arch
void ModelClass::InitLine()
{
    SetNodeCount(parm1,parm2);
    SetBufferSize(1,parm2);
    int LastStringNum=-1;
    int chan,idx;
    int ChanIncr=SingleChannel ?  1 : 3;
    size_t NodeCount=GetNodeCount();
    for(size_t n=0; n<NodeCount; n++)
    {
        if (Nodes[n]->StringNum != LastStringNum)
        {
            LastStringNum=Nodes[n]->StringNum;
            chan=stringStartChan[LastStringNum];
            idx=0;
        }
        Nodes[n]->ActChan=chan;
        chan+=ChanIncr;
        size_t CoordCount=GetCoordCount(n);
        for(size_t c=0; c < CoordCount; c++)
        {
            Nodes[n]->Coords[c].bufX=IsLtoR ? idx : parm2-idx-1;
            Nodes[n]->Coords[c].bufY=0;
            idx++;
        }
    }
}
Exemplo n.º 6
0
void
Sampler::fillBuffer(short *s, unsigned int len)
{
	if(!usecount) return;
	SRC_TYPE srcType = src;
	if(needResample) {
		needFloat = true;
		if(len > resBufferLen) {
			SetResBufferSize(len);
		}
		unsigned int rLen = resampler->res_push_check(len);
		if(rLen > bufferLen) {
			SetBufferSize(rLen);
		}
		switch(src){
			case SRC_MONOSHORT:
				srcType = SRC_MONOFLOAT;
				ShortToFloat(s, resampleBuffer, len);
				len = resampler->res_push_interleaved(floatBuffer, resampleBuffer, len);
				return _fillBuffer(floatBuffer, len, SRC_MONOFLOAT);
			case SRC_STEREOSHORT:
				srcType = SRC_STEREOFLOAT;
				ShortToFloat((short *)s, resampleBuffer, len*2);
				len = resampler->res_push_interleaved(floatBuffer, resampleBuffer, len);
				return _fillBuffer(floatBuffer, len, SRC_STEREOFLOAT);
			default:
				return;
		}
	}
	_fillBuffer(s, len, srcType);
}
Exemplo n.º 7
0
void	AudioThruEngine::SetOutputDevice(AudioDeviceID output)
{
	Stop();
	mOutputDevice.Init(output, false);
	SetBufferSize(mBufferSize);
	Start();
}
Exemplo n.º 8
0
FileIO::FileIO( void )
{
	size = -1;
	SetBufferSize();
	file = NULL;
	filepath = NULL;
}
Exemplo n.º 9
0
void ArchesModel::InitModel() {
    int NumArches=parm1;
    int SegmentsPerArch=parm2;
    arc = wxAtoi(ModelXml->GetAttribute("arc", "180"));

    
    SetBufferSize(NumArches,SegmentsPerArch);
    if (SingleNode) {
        SetNodeCount(NumArches * SegmentsPerArch, parm3,rgbOrder);
    } else {
        SetNodeCount(NumArches, SegmentsPerArch, rgbOrder);
        if (parm3 > 1) {
            for (int x = 0; x < Nodes.size(); x++) {
                Nodes[x]->Coords.resize(parm3);
            }
        }
    }
    screenLocation.SetRenderSize(SegmentsPerArch, NumArches);
    
    for (int y=0; y < NumArches; y++) {
        for(int x=0; x<SegmentsPerArch; x++) {
            int idx = y * SegmentsPerArch + x;
            Nodes[idx]->ActChan = stringStartChan[y] + x*GetNodeChannelCount(StringType);
            Nodes[idx]->StringNum=y;
            for(size_t c=0; c < GetCoordCount(idx); c++) {
                Nodes[idx]->Coords[c].bufX=IsLtoR ? x : SegmentsPerArch-x-1;
                Nodes[idx]->Coords[c].bufY=isBotToTop ? y : NumArches-y-1;
            }
        }
    }
    SetArchCoord();
}
Exemplo n.º 10
0
CString::CString( int _size )
{
    str = 0;
    size = 0;

    if ( SetBufferSize( _size ) ) str[0] = '\0';
    length = 0;
}
Exemplo n.º 11
0
void	AudioThruEngine::SetInputDevice(AudioDeviceID input)
{
	Stop();
	mInputDevice.Init(input, true);
	SetBufferSize(mBufferSize);
	mInputBuffer->Clear();
	Start();
}
Exemplo n.º 12
0
Series::Series(size_t bufferSize, int rangeId, size_t offset, wxString label, wxColor color, int precision) :
	m_rangeId(rangeId),
	m_offset(offset),
	m_label(label),
	m_color(color),
	m_precision(precision)
	{
	SetBufferSize(bufferSize);
	}
Exemplo n.º 13
0
CBinaryStream::CBinaryStream() : //m_hFile(INVALID_HANDLE_VALUE),
								 m_pBuffer(NULL),
								 m_nBufLen(0),
								 m_nBufPos(0),
								 m_nCurSector(0),
								 m_nCurSectorPos(0)
{
	SetBufferSize(8*2048); // 8 * sector size
}
Exemplo n.º 14
0
EXPORT int CALL RomOpen(void)
{
    if (!l_PluginInit)
        return 0;

    SetSamplingRate(GameFreq);
	SetBufferSize(DEFAULT_BUFFER_SIZE);
    return 1;
}
Exemplo n.º 15
0
/*************************************
 * Expand
 *************************************/
SHVBool SHVBufferPtr::Expand(int expandBy)
{
	if ( (expandBy < 0 && ((size_t)(-expandBy) > BufferSize)) ||
	     (expandBy > 0 && ((size_t)(expandBy+BufferSize) < BufferSize)) )
	{
		return SHVBufferC::ErrGeneric;
	}
	
	return SetBufferSize(expandBy+BufferSize,BufferSize);
}
Exemplo n.º 16
0
/*----------------------------------------------------------------------
|   NPT_DataBuffer::Reserve
+---------------------------------------------------------------------*/
NPT_Result
NPT_DataBuffer::Reserve(NPT_Size size)
{
    if (size <= m_BufferSize) return NPT_SUCCESS;

    // try doubling the buffer to accomodate for the new size
    NPT_Size new_size = m_BufferSize*2;
    if (new_size < size) new_size = size;
    return SetBufferSize(new_size);
}
Exemplo n.º 17
0
// parm3 is number of points
// top left=top ccw, top right=top cw, bottom left=bottom cw, bottom right=bottom ccw
void ModelClass::InitStar()
{
    if (parm3 < 2) parm3=2; // need at least 2 arms
    SetNodeCount(parm1,parm2);
    int numlights=parm1*parm2;
    SetBufferSize(numlights+1,numlights+1);
    int LastStringNum=-1;
    int chan,cursegment,nextsegment,x,y;
    int offset=numlights/2;
    int numsegments=parm3*2;
    double segstart_x,segstart_y,segend_x,segend_y,segstart_pct,segend_pct,r,segpct,dseg;
    double dpct=1.0/(double)numsegments;
    double OuterRadius=offset;
    double InnerRadius=OuterRadius/2.618034;    // divide by golden ratio squared
    double pct=isBotToTop ? 0.5 : 0.0;          // % of circle, 0=top
    double pctIncr=1.0 / (double)numlights;     // this is cw
    if (IsLtoR != isBotToTop) pctIncr*=-1.0;    // adjust to ccw
    int ChanIncr=SingleChannel ?  1 : 3;
    size_t NodeCount=GetNodeCount();
    for(size_t n=0; n<NodeCount; n++)
    {
        if (Nodes[n]->StringNum != LastStringNum)
        {
            LastStringNum=Nodes[n]->StringNum;
            chan=stringStartChan[LastStringNum];
        }
        Nodes[n]->ActChan=chan;
        chan+=ChanIncr;
        size_t CoordCount=GetCoordCount(n);
        for(size_t c=0; c < CoordCount; c++)
        {
            cursegment=(int)((double)numsegments*pct) % numsegments;
            nextsegment=(cursegment+1) % numsegments;
            segstart_pct=(double)cursegment / numsegments;
            segend_pct=(double)nextsegment / numsegments;
            dseg=pct - segstart_pct;
            segpct=dseg / dpct;
            r=cursegment%2==0 ? OuterRadius : InnerRadius;
            segstart_x=r*sin(segstart_pct*2.0*M_PI);
            segstart_y=r*cos(segstart_pct*2.0*M_PI);
            r=nextsegment%2==0 ? OuterRadius : InnerRadius;
            segend_x=r*sin(segend_pct*2.0*M_PI);
            segend_y=r*cos(segend_pct*2.0*M_PI);
            // now interpolate between segstart and segend
            x=(segend_x - segstart_x)*segpct + segstart_x + offset + 0.5;
            y=(segend_y - segstart_y)*segpct + segstart_y + offset + 0.5;
            Nodes[n]->Coords[c].bufX=x;
            Nodes[n]->Coords[c].bufY=y;
            pct+=pctIncr;
            if (pct >= 1.0) pct-=1.0;
            if (pct < 0.0) pct+=1.0;
        }
    }
}
Exemplo n.º 18
0
CString & CString::Set(const char *_str, unsigned int maxSize)
{
	if (_str) {
		if (_str != str) {
			length = min(strlen(_str), maxSize);

			if (SetBufferSize(length + 1))
				sniprintf(str, length + 1, "%s", _str);
			else
				length = 0;
		}
	}
	else {
		length = 0;
		if (SetBufferSize(length + 1))
			str[0] = '\0';
	}

	return *this;
}
Exemplo n.º 19
0
CString & CString::operator = (const char *_str)
{
	if (_str) {
		if (_str != str) {
			length = strlen(_str);

			if (SetBufferSize(length + 1))
				strcpy(str, _str);
			else
				length = 0;
		}
	}
	else {
		length = 0;
		if (SetBufferSize(length + 1))
			str[0] = '\0';
	}

	return *this;
}
Exemplo n.º 20
0
FileReader::FileReader(string filename) :
    filename(filename)
{
    // create a handle to a file
    fileHandle = fopen(filename.c_str(), "r");
    if (fileHandle == NULL)
        throw FileNotFoundException();

    buffer = NULL;
    // set default bufferSize
    SetBufferSize(1024);
}
Exemplo n.º 21
0
/**
* @brief   create the Cyc Buffer, malloc memory
*
* not need to call setBufferSize function
* @author hankejia
* @date 2012-07-05
* @param[in] pthis   the pointer point to the CCycBuffer.
* @param[in] iSize   the cyc buffer size.
* @return T_S32
* @retval if return 0, create cyc buffer success, otherwise failed
*/
static T_S32 CreateCycBufferEx( T_pVOID pthis, T_S32 iSize )
{
    CCycBuffer *this = ( CCycBuffer * )pthis;
    T_S32 ret = 0;

    ret = SetBufferSize( this, iSize );
    if ( ret < 0 )
        return ret;

    ret = CreateCycBuffer( this );
    return ret;
}
Exemplo n.º 22
0
// CONSTRUCTOR
PlayWavStream::PlayWavStream()
	: OSndStream()
{

	SetBufferSize( STREAMBUFFERSIZE );

	m_mtWavOut.Lock();

	m_pWavOut = NULL;

	m_mtWavOut.Unlock();

}
Exemplo n.º 23
0
CString & CString::operator += (char c)
{
	if (c) {
		if (SetBufferSize(length + 2)) {
			str[length++] = c;
			str[length] = 0;
		}
		else
			length = 0;
	}

	return *this;
}
Exemplo n.º 24
0
void 
Sampler::_fillBuffer(float *s, unsigned int len, SRC_TYPE typ)
{
	float * fb;
	if(len > bufferLen)
		SetBufferSize(len);
	usedBufferLen = len;
	fb = floatBuffer;
	len *= inChans;
	while(len--) 
		*(fb++) = *(s++);
	if(needShort)
		FloatToShort();
}
Exemplo n.º 25
0
void 
Sampler::_fillBuffer(short *s, unsigned int len, SRC_TYPE typ)
{
	short * sb;
	if(len > bufferLen)
		SetBufferSize(len);
	usedBufferLen = len;
	sb = shortBuffer;
	len *= inChans;
	while(len--) 
		*(sb++) = *(s++);
	if(needFloat || needResample)
		ShortToFloat();
}
Exemplo n.º 26
0
/*************************************
 * Add
 *************************************/
SHVBool SHVBufferPtr::Add(const SHVBufferC& buffer)
{
size_t oldSize = BufferSize;
SHVBool retVal;
	
	retVal = SetBufferSize(BufferSize+buffer.GetSize(),BufferSize);
	
	if (retVal)
	{
		memcpy(BufferPtr+oldSize,buffer.GetBufferConst(),buffer.GetSize());
	}
	
	return retVal;
}
Exemplo n.º 27
0
// initialize buffer coordinates
// parm1=NumStrings
// parm2=PixelsPerString
// parm3=StrandsPerString
void ModelClass::InitVMatrix()
{
    int y,x,idx,stringnum,segmentnum,yincr;
    int NumStrands=parm1*parm3;
    int PixelsPerStrand=parm2/parm3;
    int PixelsPerString=PixelsPerStrand*parm3;
    SetBufferSize(PixelsPerStrand,NumStrands);
    SetNodeCount(parm1,PixelsPerString);
    SetRenderSize(PixelsPerStrand,NumStrands);

    // create output mapping
    if (SingleNode)
    {
        x=0;
        for (size_t n=0; n<Nodes.size(); n++)
        {
            Nodes[n]->ActChan = stringStartChan[n];
            y=0;
            yincr=1;
            for (size_t c=0; c<PixelsPerString; c++)
            {
                Nodes[n]->Coords[c].bufX=IsLtoR ? x : NumStrands-x-1;
                Nodes[n]->Coords[c].bufY=y;
                y+=yincr;
                if (y < 0 || y >= PixelsPerStrand)
                {
                    yincr=-yincr;
                    y+=yincr;
                    x++;
                }
            }
        }
    }
    else
    {
        for (x=0; x < NumStrands; x++)
        {
            stringnum=x / parm3;
            segmentnum=x % parm3;
            for(y=0; y < PixelsPerStrand; y++)
            {
                idx=stringnum * PixelsPerString + segmentnum * PixelsPerStrand + y;
                Nodes[idx]->ActChan = stringStartChan[stringnum] + segmentnum * PixelsPerStrand*3 + y*3;
                Nodes[idx]->Coords[0].bufX=IsLtoR ? x : NumStrands-x-1;
                Nodes[idx]->Coords[0].bufY= isBotToTop == (segmentnum % 2 == 0) ? y:PixelsPerStrand-y-1;
                Nodes[idx]->StringNum=stringnum;
            }
        }
    }
}
Exemplo n.º 28
0
// initialize buffer coordinates
// parm1=NumStrings
// parm2=PixelsPerString
// parm3=StrandsPerString
void ModelClass::InitHMatrix()
{
    int y,x,idx,stringnum,segmentnum,xincr;
    int NumStrands=parm1*parm3;
    int PixelsPerStrand=parm2/parm3;
    int PixelsPerString=PixelsPerStrand*parm3;
    SetBufferSize(NumStrands,PixelsPerStrand);
    SetNodeCount(parm1,PixelsPerString);
    SetRenderSize(NumStrands,PixelsPerStrand);

    // create output mapping
    if (SingleNode)
    {
        y=0;
        for (size_t n=0; n<Nodes.size(); n++)
        {
            Nodes[n]->ActChan = stringStartChan[n];
            x=0;
            xincr=1;
            for (size_t c=0; c<PixelsPerString; c++)
            {
                Nodes[n]->Coords[c].bufX=x;
                Nodes[n]->Coords[c].bufY=isBotToTop ? y :NumStrands-y-1;
                x+=xincr;
                if (x < 0 || x >= PixelsPerStrand)
                {
                    xincr=-xincr;
                    x+=xincr;
                    y++;
                }
            }
        }
    }
    else
    {
        for (y=0; y < NumStrands; y++)
        {
            stringnum=y / parm3;
            segmentnum=y % parm3;
            for(x=0; x<PixelsPerStrand; x++)
            {
                idx=stringnum * PixelsPerString + segmentnum * PixelsPerStrand + x;
                Nodes[idx]->ActChan = stringStartChan[stringnum] + segmentnum * PixelsPerStrand*3 + x*3;
                Nodes[idx]->Coords[0].bufX=IsLtoR != (segmentnum % 2 == 0) ? PixelsPerStrand-x-1 : x;
                Nodes[idx]->Coords[0].bufY= isBotToTop ? y :NumStrands-y-1;
                Nodes[idx]->StringNum=stringnum;
            }
        }
    }
}
Exemplo n.º 29
0
CString & CString::operator += (const CString &_s)
{
	if (str) {
		int slen = _s.length;

		if (SetBufferSize(length + slen + 1)) {
			strcpy(str + length, _s);
			length += slen;
		}
		else
			length = 0;
	}

	return *this;
}
Exemplo n.º 30
0
CString & CString::operator += (const char *_str)
{
	if (str && _str) {
		int slen = strlen(_str);

		if (SetBufferSize(length + slen + 1)) {
			strcpy(str + length, _str);
			length += slen;
		}
		else
			length = 0;
	}

	return *this;
}