예제 #1
0
OSStatus			AUPinkNoise::Initialize()
{
	const CAStreamBasicDescription & theDesc = GetStreamFormat(kAudioUnitScope_Output, 0);
	
	mPink = new PinkNoiseGenerator::PinkNoiseGenerator(theDesc.mSampleRate);
	
	return noErr;
}
예제 #2
0
//--------------------------------------------------------------------------------
OSStatus	BS2B::Initialize()
{
	OSStatus status = AUEffectBase::Initialize();
    
	if (status == noErr)
	{
        // What does this do?
		const AudioUnitElement elem = 0;
		Reset(kAudioUnitScope_Global, elem);
        
		if ( GetStreamFormat(kAudioUnitScope_Input, elem).mChannelsPerFrame != GetStreamFormat(kAudioUnitScope_Output, elem).mChannelsPerFrame )
		{
			if ( ProcessesInPlace() )
			{
				SetProcessesInPlace(false);
				PropertyChanged(kAudioUnitProperty_InPlaceProcessing, kAudioUnitScope_Global, elem);
			}
		}
	}
    
	return status;
}
예제 #3
0
//--------------------------------------------------------------------------------
OSStatus	Stereo::Initialize()
{
	OSStatus status = AUEffectBase::Initialize();

	if (status == noErr)
	{
		bufsize = (long) (kBufferSize_Seconds * GetSampleRate());
		buffer = (float*) malloc(bufsize * sizeof(float));

		const AudioUnitElement elem = 0;
		Reset(kAudioUnitScope_Global, elem);

		if ( GetStreamFormat(kAudioUnitScope_Input, elem).mChannelsPerFrame != GetStreamFormat(kAudioUnitScope_Output, elem).mChannelsPerFrame )
		{
			if ( ProcessesInPlace() )
			{
				SetProcessesInPlace(false);
				PropertyChanged(kAudioUnitProperty_InPlaceProcessing, kAudioUnitScope_Global, elem);
			}
		}
	}

	return status;
}
예제 #4
0
OSStatus MT32Synth::Initialize() {
    
    destFormat = GetStreamFormat(kAudioUnitScope_Output, 0);
    
    AudioStreamBasicDescription sourceDescription;
    sourceDescription.mSampleRate = 32000;
    sourceDescription.mBytesPerFrame = 4;
    sourceDescription.mBitsPerChannel = 16;
    sourceDescription.mFormatID = kAudioFormatLinearPCM;
    sourceDescription.mBytesPerPacket = 4;
    sourceDescription.mChannelsPerFrame = 2;
    sourceDescription.mFormatFlags = kAudioFormatFlagIsSignedInteger;
    sourceDescription.mFramesPerPacket = 1;
    sourceDescription.mReserved = 0;
    
    AudioConverterNew(&sourceDescription, &destFormat, &audioConverterRef);
    MT32Emu::FileStream controlROMFile;
    MT32Emu::FileStream pcmROMFile;
    
    if(!controlROMFile.open("/Library/MT32/MT32_CONTROL.ROM")) {
        printf("Error opening MT32_CONTROL.ROM\n");
    }
    
    if(!pcmROMFile.open("/Library/MT32/MT32_PCM.ROM")) {
        printf("Error opening MT32_PCM.ROM\n");
    }
    
    romImage = MT32Emu::ROMImage::makeROMImage(&controlROMFile);
    pcmRomImage = MT32Emu::ROMImage::makeROMImage(&pcmROMFile);
    
    synth = new MT32Emu::Synth();
    synth->open(*romImage, *pcmRomImage);
    
    MT32Emu::ROMImage::freeROMImage(romImage);
    MT32Emu::ROMImage::freeROMImage(pcmRomImage);
    
    sendMIDI(0xC1, 0x00, 0x00, 0x00);
    MusicDeviceBase::Initialize();
    
    synth->setOutputGain(2.0);
    
    return noErr;
}
예제 #5
0
파일: avinfo.cpp 프로젝트: joyfish/os45
// private
HRESULT AVInfo::DetermineStreamIndices()
{
    _ASSERT(m_pMediaDet);

    HRESULT hr = S_OK;

    long iStreamCount = 0;
    if (SUCCEEDED(hr))
        hr = GetStreamCount(&iStreamCount);

    int iStreamId = 0;
    while (SUCCEEDED(hr) && iStreamId < iStreamCount)
    {
        AM_MEDIA_TYPE mt;
        hr = GetStreamFormat(iStreamId, &mt);

        if (SUCCEEDED(hr))
        {
            if (mt.majortype == MEDIATYPE_Video)
                m_iVideoIndex = iStreamId;
            else if (mt.majortype == MEDIATYPE_Audio)
                m_iAudioIndex = iStreamId;

            FreeMediaType(mt);
        }

        ++iStreamId;
    }

    if (SUCCEEDED(hr))
    {
        if (m_iVideoIndex == -2)
            m_iVideoIndex = -1; // video not found
        if (m_iAudioIndex == -2)
            m_iAudioIndex = -1; // audio not found
    }

    return hr;
}
예제 #6
0
bool SkImageDecoder::DecodeStream(SkStreamRewindable* stream, SkBitmap* bm, SkColorType pref,
                                  Mode mode, Format* format) {
    SkASSERT(stream);
    SkASSERT(bm);

    bool success = false;
    SkImageDecoder* codec = SkImageDecoder::Factory(stream);

    if (codec) {
        success = codec->decode(stream, bm, pref, mode) != kFailure;
        if (success && format) {
            *format = codec->getFormat();
            if (kUnknown_Format == *format) {
                if (stream->rewind()) {
                    *format = GetStreamFormat(stream);
                }
            }
        }
        delete codec;
    }
    return success;
}
예제 #7
0
//_____________________________________________________________________________
//
OSStatus AUEffectBase::Initialize()
{
		// get our current numChannels for input and output
	SInt16 auNumInputs = (SInt16) GetInput(0)->GetStreamFormat().mChannelsPerFrame;
	SInt16 auNumOutputs = (SInt16) GetOutput(0)->GetStreamFormat().mChannelsPerFrame;

		// does the unit publish specific information about channel configurations?
    const AUChannelInfo *auChannelConfigs = NULL;
    UInt32 numIOconfigs = SupportedNumChannels(&auChannelConfigs);

    if ((numIOconfigs > 0) && (auChannelConfigs != NULL))
    {
        bool foundMatch = false;
        for (UInt32 i = 0; (i < numIOconfigs) && !foundMatch; ++i)
        {
            SInt16 configNumInputs = auChannelConfigs[i].inChannels;
            SInt16 configNumOutputs = auChannelConfigs[i].outChannels;
            if ((configNumInputs < 0) && (configNumOutputs < 0))
            {
					// unit accepts any number of channels on input and output
                if (((configNumInputs == -1) && (configNumOutputs == -2))
					|| ((configNumInputs == -2) && (configNumOutputs == -1)))
                {
				    foundMatch = true;
					// unit accepts any number of channels on input and output IFF they are the same number on both scopes
                }
				else if (((configNumInputs == -1) && (configNumOutputs == -1)) && (auNumInputs == auNumOutputs))
                {
				    foundMatch = true;
					// unit has specified a particular number of channels on both scopes
                }
				else
                    continue;
            }
            else
            {
					// the -1 case on either scope is saying that the unit doesn't care about the
					// number of channels on that scope
                bool inputMatch = (auNumInputs == configNumInputs) || (configNumInputs == -1);
                bool outputMatch = (auNumOutputs == configNumOutputs) || (configNumOutputs == -1);
                if (inputMatch && outputMatch)
                    foundMatch = true;
            }
        }
        if (!foundMatch)
            return kAudioUnitErr_FormatNotSupported;
    }
    else
    {
			// there is no specifically published channel info
			// so for those kinds of effects, the assumption is that the channels (whatever their number)
			// should match on both scopes
        if ((auNumOutputs != auNumInputs) || (auNumOutputs == 0))
		{
		    return kAudioUnitErr_FormatNotSupported;
		}
    }

    MaintainKernels();

	mMainOutput = GetOutput(0);
	mMainInput = GetInput(0);

	const CAStreamBasicDescription& format = GetStreamFormat(kAudioUnitScope_Output, 0);
	format.IdentifyCommonPCMFormat(mCommonPCMFormat, NULL);
	mBytesPerFrame = format.mBytesPerFrame;

    return noErr;
}
예제 #8
0
파일: Scan.cpp 프로젝트: BOTCrusher/sagetv
void CScan::ProcessScan( unsigned char* pData, long lDataLen )
{
	int  nScanState;
	if ( m_nScanState == DONE_SCAN ) 
		return;
		
	if ( m_bScanFileCache )
		CacheChannelScanData( pData, lDataLen );

	if ( !m_bScanFileCache || m_bScanFileCache && !IsCacheDataFull( ) )
		PushChannelScanTunerData( pData, lDataLen );
	else
		PushChannelScanFileData( );

	nScanState = IsChannelInfoReady( m_pScan );
	if ( nScanState == 2 ) //psi channels is ready
	{
		unsigned short iStreamFormat, iSubFormat;
		if ( GetStreamFormat( m_pScan, &iStreamFormat, &iSubFormat ) )
		{
			m_nStreamFormat = (unsigned char)iStreamFormat;
			m_nStreamSubFormat = (unsigned char)iSubFormat;
		}
		if ( IsQAMStream( &m_pScan->tune ) )
		{
			m_Tune.stream_format = (unsigned char)m_nStreamFormat;
			m_Tune.sub_format    = (unsigned char)m_nStreamSubFormat;
			ResetChannelScan( m_pScan );
			DoChannelScan( m_pScan, NAKED_SCAN );
			ChannelScanTune( m_pScan, &m_Tune ); 
			m_nScanState = NAKED_SCAN;
		} else
			m_nScanState = DONE_SCAN;
	} else
	if ( nScanState == 3 ) //naked channels is ready
	{
		MergeChannelListProgramList( m_pScan );
		m_nScanState = DONE_SCAN;
		SageLog(( _LOG_TRACE, 3, TEXT("*********** Scan done ************") )); 
	} else
	if ( nScanState > 0 ) //maxium parsing data
	{
		if ( nScanState == 4 )
			SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop PSI parsing (maxium bytes searching).") ));
		else
		if ( nScanState == 5 )
			SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop PSI parsing, no nit, no channel PSI (%d ms)"), UpdateTimeClock( m_pScan, 0 ) ));
		else
		if ( nScanState == 10 )
			SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop PSI parsing, timeout (%d ms)."), UpdateTimeClock( m_pScan, 0 ) ));
		else
		if ( nScanState == 6 )
		    SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop naked parsing (maxium bytes searching), no pmt.).") ));
		else
		if ( nScanState == 7 )
			SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop naked parsing (maxium bytes searching), no clear channel.).") ));
		else
			SageLog(( _LOG_TRACE, 3, TEXT("\t**** Stop PSI parsing, unkonw %d (%d ms)."), nScanState, UpdateTimeClock( m_pScan, 0 ) ));

		if ( m_nScanState == PSI_SCAN && 
			( IsQAMStream( &m_pScan->tune ) || 
			  IsDVBSStream( &m_pScan->tune ) && IsNakedStream( m_pScan ) ) ) //naked DVB-S stream in USA
		{
			SageLog(( _LOG_TRACE, 3, TEXT("*********** Start scaning naked channels ************") )); 
			ResetChannelScan( m_pScan );
			DoChannelScan( m_pScan, NAKED_SCAN );
			ChannelScanTune( m_pScan, &m_Tune ); 
			m_nScanState = NAKED_SCAN; 

		} else
		{
			SageLog(( _LOG_TRACE, 3, TEXT("*********** Scan done (state:%d %s naked:%d )************"),
				m_nScanState, StreamFormatString(m_pScan->tune.stream_format, m_pScan->tune.sub_format), 
				IsNakedStream( m_pScan ) )); 
			m_nScanState = DONE_SCAN;
		}
	} 

}