예제 #1
0
AEStreamHandle* CAddonCallbacksAudioEngine::AudioEngine_MakeStream(AEDataFormat DataFormat, unsigned int SampleRate, unsigned int EncodedSampleRate, enum AEChannel *Channels, unsigned int Options)
{
  if (!Channels)
  {
    CLog::Log(LOGERROR, "CAddonCallbacksAudioEngine - %s - Invalid input! Channels is a NULL pointer!", __FUNCTION__);
    return NULL;
  }

  CAEChannelInfo channelInfo(Channels);
  return CAEFactory::MakeStream(DataFormat, SampleRate, EncodedSampleRate, channelInfo, Options);
}
예제 #2
0
void GenieAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
    

    
    const int numSamples = buffer.getNumSamples();

    
    AudioSourceChannelInfo channelInfo(buffer);
    mixerAudioSource.getNextAudioBlock(channelInfo); 
    keyboardState.processNextMidiBuffer(midiMessages, 0, numSamples, true);
    
    
    //Utilise the following method for any audio processing if needed
//    float LchannelData;
//    float RchannelData;
//    
//    const float *pfInBuffer0;
//    const float *pfInBuffer1;
    
//    float *channel0 = buffer.getArrayOfChannels()[0]; //A pointer to the buffer for channel one
//    float *channel1 = buffer.getArrayOfChannels()[1]; //A pointer to the buffer for channel two

//    // This is the place where you'd normally do the guts of your plugin's
//    // audio processing...
//
//    
//    
//    //While the frames to process remain <0 do the following processing
//    while (numSamples --)
//    {
//        LchannelData = RchannelData = 0.f;
//        
//      //  *channel0 = LchannelData;
//        //*channel1 = RchannelData;
//        
//        //Move the pointer to next frame. Stride allows the possibilty of interlacing channels to a single buffer to speed things up if the project gets big
//       // channel0 += STRIDE;
//        //channel1 += STRIDE;
//    }
//    
//    // In case we have more outputs than inputs, we'll clear any output
//    // channels that didn't contain input data, (because these aren't
//    // guaranteed to be empty - they may contain garbage).
//    for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
//    {
//       // buffer.clear (i, 0, buffer.getNumSamples());
//    }
//    
//    
    
}
예제 #3
0
// we got a channel ID notification
void ANTChannel::channelId(unsigned char *ant_message) {

    unsigned char *message=ant_message+2;

    device_number=CHANNEL_ID_DEVICE_NUMBER(message);
    device_id=CHANNEL_ID_DEVICE_TYPE_ID(message);
    state=MESSAGE_RECEIVED;
    emit channelInfo(number, device_number, device_id);
    setId();

    // if we were searching,
    if (channel_type_flags & CHANNEL_TYPE_QUICK_SEARCH) {
        parent->sendMessage(ANTMessage::setSearchTimeout(number, (int)(timeout_lost/2.5)));
    }
    channel_type_flags &= ~CHANNEL_TYPE_QUICK_SEARCH;
}
예제 #4
0
// we got a channel ID notification
void ANTChannel::channelId(unsigned char *ant_message) {

    unsigned char *message=ant_message+2;

    device_number=CHANNEL_ID_DEVICE_NUMBER(message);
    device_id=CHANNEL_ID_DEVICE_TYPE_ID(message);
    state=MESSAGE_RECEIVED;
    emit channelInfo(number, device_number, device_id);
    setId();

    // if we were searching,
    if (channel_type_flags & CHANNEL_TYPE_QUICK_SEARCH) {
        parent->sendMessage(ANTMessage::setSearchTimeout(number, (int)(timeout_lost/2.5)));
    }
    channel_type_flags &= ~CHANNEL_TYPE_QUICK_SEARCH;

    //XXX channel_manager_start_waiting_search(self->parent);
    // if we are quarq channel, hook up with the ant+ channel we are connected to
    //XXX channel_manager_associate_control_channels(self->parent);
}
예제 #5
0
// When this Seaboard::Listener object receives midi messages, we overwrite the following methods and implement our desired response.
void SeaboardVisualiser::seaboardDidGetNoteOn(const juce::MidiMessage &message)
{
	/*
	 We will set up a ValueTree object and add it as a child to the SeaboardData value tree. Its name will be set to the channel number that it is assigned to.
	 */
	
	// Get the relevant midi note information from the incoming message
	int channel = message.getChannel();
	int note = message.getNoteNumber();
	
	// Setup the name for the new child ValueTree structure.
	String childName = kChannelNo + String(channel);
	ValueTree channelInfo(childName);
	
	// Add the note information to the ValueTree structure.
	channelInfo.setProperty(kNoteNo, note, 0);
	channelInfo.addListener(this);
	
	// Add the note value tree as a child to the seaboard data value tree.
	theSeaboardData.addChild(channelInfo, -1, 0);
}
// -----------------------------------------------------------------------------
// CSensrvTest::OpenChannelL
// Parameters: Open-Close Count(TInt)
// 
// -----------------------------------------------------------------------------
//
TInt CSensrvTest::OpenClosePerformanceL( CStifItemParser& aItem )
    {
    RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL") );
    
    // Get parameter
    TInt count;
    TInt err = aItem.GetNextInt( count );
    if( err )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: parameter error = %d"), err );
        return err;
        }
    
    TBufC8<1> nullBuf( KNullDesC8 );
    TSensrvChannelInfo channelInfo( 0, ESensrvContextNotdefined, ESensrvQuantityNotdefined, 0, nullBuf, nullBuf, 0 );
    iChannelInfoList.Reset();
    err = FindChannels( iChannelInfoList, channelInfo );
    if( err )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: FindChanels error: %d"), err );
        return err;
        }
    if( iChannelInfoList.Count == 0 )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL: Channel not found" ) );
        return KErrNotFound;
        }
    if( !iSensorChannel )
        {
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Create iSensorChannel...") );
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - ChannelId = %d "), iChannelInfoList[ 0 ].iChannelId );
        iSensorChannel = CSensrvSensorChannel::NewL( iChannelInfoList[ 0 ] );
        RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - iSensorChannel Created") );
        }
        
    TTime startTime;
    startTime.HomeTime();
    
    for( TInt i = 1; i <= count; ++i )
        {
        TRAP( err, iSensorChannel->OpenChannelL() );
        if( err )
            {
            //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Open channel error %d"), err );
            }
            
        TRAP( err, iSensorChannel->CloseChannelL() );
        if( err )
            {
            //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Close channel error %d"), err );
            }
        
        //RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Open-Close [%d]"), i );
        
        }
        
    TTime endTime;
    endTime.HomeTime();  
    
    TTimeIntervalMicroSeconds overallTime =  endTime.MicroSecondsFrom( startTime );
    
    RDebug::Print( _L("CSensrvTest::OpenClosePerformanceL - Overall time %d micro seconds"), overallTime );
     
    
    return KErrNone;
    
    }
// -----------------------------------------------------------------------------
// CSensrvTestCases::CheckFindResult
//
// -----------------------------------------------------------------------------
//
TInt CSensrvTestObserver::CheckFindResult( TSensrvChannelInfo& aSearchConditions, RSensrvChannelInfoList aChannelInfoList )
    {    
    COMPONENT_TRACE( _L("CSensrvTestObserver::CheckFindResult") );
    COMPONENT_TRACE( ( _L("### conditions: ChannelId=%d, ContextType=%d, Quantity=%d, ChannelType=%d, Location=%S, VendorId=%S, DataItemSize=%d"),
                     aSearchConditions.iChannelId, aSearchConditions.iContextType, aSearchConditions.iQuantity, aSearchConditions.iChannelType,
                     &aSearchConditions.iLocation, &aSearchConditions.iVendorId, aSearchConditions.iDataItemSize ));

    // Find all channels
    TBufC8<1> nullBuf( KNullDesC8 );
    TSensrvChannelInfo channelInfo( 0, ESensrvContextTypeNotDefined, ESensrvQuantityNotdefined, 0, nullBuf, nullBuf, 0, 0 );
    RSensrvChannelInfoList allChannelList(10);
    CleanupClosePushL( allChannelList );
    CSensrvChannelFinder*  channelFinder = CSensrvChannelFinder::NewLC();
    TRAPD( err, channelFinder->FindChannelsL( allChannelList, channelInfo ));
    if( err )
        {
        COMPONENT_TRACE( ( _L("CSensrvTestCases::CheckFindResult: Find all channels Leave: %d"), err ));
        return err;
        }

    //
    RSensrvChannelInfoList acceptedChannels(10);
    for( TInt i = 0; i < allChannelList.Count(); i++ )
        {
        if( allChannelList[i].IsMatch( aSearchConditions ) )
            {
            acceptedChannels.Append( allChannelList[i] );
            }
        }

    if( acceptedChannels.Count() != aChannelInfoList.Count() )
        {
        // Test fails.
        COMPONENT_TRACE( ( _L("CSensrvTestCases::CheckFindResult: Test fails") ));
        COMPONENT_TRACE( ( _L("   required count %d"), acceptedChannels.Count() ));
        COMPONENT_TRACE( ( _L("   found channels count %d"), aChannelInfoList.Count() ));
        return KErrGeneral;
        }

    TBool testFail( EFalse );
    // Check all channels infos
    for( TInt i = 0; i < aChannelInfoList.Count(); i++ )
        {
        COMPONENT_TRACE( ( _L("     ###channel info [%d]:"), i ));
        COMPONENT_TRACE( ( _L("     ### ChannelId=%d, ContextType=%d, Quantity=%d, ChannelType=%d, Location=%S, VendorId=%S, DataItemSize=%d"),
                   aChannelInfoList[i].iChannelId, aChannelInfoList[i].iContextType, aChannelInfoList[i].iQuantity, aChannelInfoList[i].iChannelType,
                   &aChannelInfoList[i].iLocation, &aChannelInfoList[i].iVendorId, aChannelInfoList[i].iDataItemSize ));

        TBool found( EFalse );
        for( TInt x = 0; x < acceptedChannels.Count(); x++ )
            {
            if( acceptedChannels[x].iChannelId == aChannelInfoList[i].iChannelId )
                {
                found = ETrue;
                break;
                }

            }
        if( found )
            {
            COMPONENT_TRACE( _L("     -OK-") );
            }
        else
            {
            COMPONENT_TRACE( _L("     -FAIL-") );
            testFail = ETrue;
            }

        }
    
    CleanupStack::PopAndDestroy( channelFinder );
    CleanupStack::PopAndDestroy( &allChannelList );    
    
    if( testFail )
        {
        return KErrGeneral;
        }
    return KErrNone;
    }    
예제 #8
0
// -----------------------------------------------------------------------------
// CSensrvTest::FindChannelsL
// 
// -----------------------------------------------------------------------------
//    
TInt CSensrvTest::CheckFindResult( TSensrvChannelInfo& aSearchConditions )
    {
    RDebug::Print( _L("CSensrvTest::CheckFindResult") );
    RDebug::Print( _L("### conditions: ChannelId=%d, ContextType=%d, Quantity=%d, ChannelType=%d, Location=%S, VendorId=%S, DataItemSize=%d"),
                   aSearchConditions.iChannelId, aSearchConditions.iContextType, aSearchConditions.iQuantity, aSearchConditions.iChannelType, 
                   &aSearchConditions.iLocation, &aSearchConditions.iVendorId, aSearchConditions.iDataItemSize );
                   
    // Find all channels
    TBufC8<1> nullBuf( KNullDesC8 );
    TSensrvChannelInfo channelInfo( 0, ESensrvContextNotdefined, ESensrvQuantityNotdefined, 0, nullBuf, nullBuf, 0 );
    RSensrvChannelInfoList allChannelList(10);
    TInt err = FindChannels( allChannelList, channelInfo );
    if( err )
        {
        RDebug::Print( _L("CSensrvTest::CheckFindResult: Find all channels Leave: %d"), err );
        return err;
        }
    
    // 
    RSensrvChannelInfoList acceptedChannels(10);
    for( TInt i = 0; i < allChannelList.Count(); i++ )
        {
        if( allChannelList[i].IsMatch( aSearchConditions ) )
            {
            acceptedChannels.Append( allChannelList[i] );
            }
        }
        
    if( acceptedChannels.Count() != iChannelInfoList.Count() )
        {
        // Test fails.
        RDebug::Print( _L("CSensrvTest::CheckFindResult: Test fails") );
        RDebug::Print( _L("   required count %d"), acceptedChannels.Count() );
        RDebug::Print( _L("   found channels count %d"), iChannelInfoList.Count() );
        return KErrGeneral;
        }
     
    TBool testFail( EFalse );
    // Check all channels infos    
    for( TInt i = 0; i < iChannelInfoList.Count(); i++ )
        {
        RDebug::Print( _L("     ###channel info [%d]:"), i );
        RDebug::Print( _L("     ### ChannelId=%d, ContextType=%d, Quantity=%d, ChannelType=%d, Location=%S, VendorId=%S, DataItemSize=%d"),
                   iChannelInfoList[i].iChannelId, iChannelInfoList[i].iContextType, iChannelInfoList[i].iQuantity, iChannelInfoList[i].iChannelType, 
                   &iChannelInfoList[i].iLocation, &iChannelInfoList[i].iVendorId, iChannelInfoList[i].iDataItemSize );
        
        TBool found( EFalse );           
        for( TInt x = 0; x < acceptedChannels.Count(); x++ )
            {
            if( acceptedChannels[x].iChannelId == iChannelInfoList[i].iChannelId )
                {
                found = ETrue;
                break;
                }
            
            }
        if( found )
            {
            RDebug::Print( _L("     -OK-") );
            }
        else
            {
            RDebug::Print( _L("     -FAIL-") );
            testFail = ETrue;
            }
        
        }
    
    if( testFail )
        {
        return KErrGeneral;
        }
    return KErrNone;
    }
예제 #9
0
void BandwidthMeter::render(int screenWidth, int screenHeight) {

    int x = BORDER_DISTANCE_HORIZ + (AREA_WIDTH >= 0 ? 0 : screenWidth + AREA_WIDTH);
    int y = BORDER_DISTANCE_VERT + (AREA_HEIGHT >= 0 ? 0 : screenHeight + AREA_HEIGHT);
    int w = glm::abs(AREA_WIDTH), h = glm::abs(AREA_HEIGHT);

    // Determine total
    float totalIn = 0.0f, totalOut = 0.0f;
    for (size_t i = 0; i < N_CHANNELS; ++i) {

        totalIn += inputStream(ChannelIndex(i)).getValue();
        totalOut += outputStream(ChannelIndex(i)).getValue();
    }
    totalIn *= UNIT_SCALE;
    totalOut *= UNIT_SCALE;
    float totalMax = glm::max(totalIn, totalOut);

    // Get font / caption metrics
    QFontMetrics const& fontMetrics = _textRenderer->metrics();
    int fontDescent = fontMetrics.descent(); 
    int labelWidthIn = fontMetrics.width(CAPTION_IN);
    int labelWidthOut = fontMetrics.width(CAPTION_OUT);
    int labelWidthInOut = glm::max(labelWidthIn, labelWidthOut);
    int labelHeight = fontMetrics.ascent() + fontDescent;
    int labelWidthUnit = fontMetrics.width(CAPTION_UNIT);
    int labelsWidth = labelWidthInOut + SPACING_RIGHT_CAPTION_IN_OUT + SPACING_LEFT_CAPTION_UNIT + labelWidthUnit;

    // Calculate coordinates and dimensions
    int barX = x + labelWidthInOut + SPACING_RIGHT_CAPTION_IN_OUT;
    int barWidth = w - labelsWidth;
    int barHeight = (h - SPACING_VERT_BARS) / 2;
    int textYcenteredLine = h - centered(labelHeight, h) - fontDescent;
    int textYupperLine = barHeight - centered(labelHeight, barHeight) - fontDescent;
    int textYlowerLine = h - centered(labelHeight, barHeight) - fontDescent;

    // Center of coordinate system -> upper left of bar
    glPushMatrix();
    glTranslatef((float)barX, (float)y, 0.0f);

    // Render captions
    glm::vec4 textColor = getColorRGBA(COLOR_TEXT);
    _textRenderer->draw(barWidth + SPACING_LEFT_CAPTION_UNIT, textYcenteredLine, CAPTION_UNIT, textColor);
    _textRenderer->draw(-labelWidthIn - SPACING_RIGHT_CAPTION_IN_OUT, textYupperLine, CAPTION_IN, textColor);
    _textRenderer->draw(-labelWidthOut - SPACING_RIGHT_CAPTION_IN_OUT, textYlowerLine, CAPTION_OUT, textColor);

    // Render vertical lines for the frame
    // TODO: I think there may be a bug in this newest code and/or the GeometryCache code, because it seems like
    // sometimes the bandwidth meter doesn't render the vertical lines
    renderVerticalLine(0, 0, h, COLOR_FRAME);
    renderVerticalLine(barWidth, 0, h, COLOR_FRAME);

    // Adjust scale
    int steps;
    double step, scaleMax;
    bool commit = false;
    do {
        steps = (_scaleMaxIndex % 9) + 2;
        step = pow(10.0, (_scaleMaxIndex / 9) - 10);
        scaleMax = step * steps;
        if (commit) {
//            printLog("Bandwidth meter scale: %d\n", _scaleMaxIndex);
            break;
        }
        if (totalMax < scaleMax * 0.5) {
            _scaleMaxIndex = glm::max(0, _scaleMaxIndex - 1);
            commit = true;
        } else if (totalMax > scaleMax) {
            _scaleMaxIndex += 1;
            commit = true;
        }
    } while (commit);

    step = scaleMax / NUMBER_OF_MARKERS;
    if (scaleMax < MIN_METER_SCALE) {
        scaleMax = MIN_METER_SCALE;
    }
    
    // Render scale indicators
    for (int j = NUMBER_OF_MARKERS; --j > 0;) {
        renderVerticalLine((barWidth * j) / NUMBER_OF_MARKERS, 0, h, COLOR_INDICATOR);
    }

    // Render bars
    int xIn = 0, xOut = 0;
    for (size_t i = 0; i < N_CHANNELS; ++i) {

        ChannelIndex chIdx = ChannelIndex(i);
        int wIn = (int)(barWidth * inputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);
        int wOut = (int)(barWidth * outputStream(chIdx).getValue() * UNIT_SCALE / scaleMax);

        if (wIn > 0) {
            renderBox(xIn, 0, wIn, barHeight, channelInfo(chIdx).colorRGBA);
        }
        xIn += wIn;

        if (wOut > 0) {
            renderBox(xOut, h - barHeight, wOut, barHeight, channelInfo(chIdx).colorRGBA);
        }
        xOut += wOut;
    }

    // Render numbers
    char fmtBuf[8];
    sprintf(fmtBuf, "%0.1f", totalIn);
    _textRenderer->draw(glm::max(xIn - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
                                PADDING_HORIZ_VALUE),
                       textYupperLine, fmtBuf, textColor);
    sprintf(fmtBuf, "%0.1f", totalOut);
    _textRenderer->draw(glm::max(xOut - fontMetrics.width(fmtBuf) - PADDING_HORIZ_VALUE,
                                PADDING_HORIZ_VALUE),
                       textYlowerLine, fmtBuf, textColor);

    glPopMatrix();

    // After rendering, indicate that no data has been sent/received since the last feed.
    // This way, the meters fall when not continuously fed.
    for (size_t i = 0; i < N_CHANNELS; ++i) {
        inputStream(ChannelIndex(i)).updateValue(0);
        outputStream(ChannelIndex(i)).updateValue(0);
    }
}
예제 #10
0
//
// ----------------------------------------------------------------------------------
// CEventChannel::RunL()
// ----------------------------------------------------------------------------------
//  
void CEventChannel::RunL()
    {
    TBuf<16> location;
    location.Copy( iChannelInfo.iLocation );
    COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - %S" ), &location ) );
    
    switch( iChannelState )
        {
        case EChannelOpening:
            {
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - EChannelOpening" ) ) );
            TInt err( KErrNone );    
            if( iStatus.Int() == KErrNone )
                {
                COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() iChannelState = EChannelOpen" ) ) );
                iChannelState = EChannelOpen;
                
                // Find data channel
                CSensrvChannelFinder* channelFinder = CSensrvChannelFinder::NewLC();
                
                TBufC8<KSensrvLocationLength> location( _L8("First0") );
                TBufC8<KSensrvVendorIdLength> vendorId( _L8( "VendorFirst" ) );
                TSensrvChannelInfo channelInfo( 0, ESensrvContextTypeNotDefined, ESensrvQuantityNotdefined, 0, location, vendorId, 0, 0 );
                RSensrvChannelInfoList channelList(10);
                
                TRAP( err, channelFinder->FindChannelsL( channelList, channelInfo ) );
                
                if( !err && channelList.Count() > 0 )
                    {
                    iChannel = CSensrvChannel::NewL( channelList[ 0 ] );
                    TRAP( err, iChannel->OpenChannelL() );
                    }
                
                CleanupStack::PopAndDestroy( channelFinder );   
                channelList.Reset();                              
                }
            if( err || iStatus.Int() != KErrNone )
                {
                COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() iChannelState = EChannelIdle" ) ) );
                iChannelState = EChannelIdle;
                if( !err )
                    {
                    err = iStatus.Int();
                    }                
                }
                
            iSsyCallback->ChannelOpened( iChannelInfo.iChannelId, err, this, iPropertyProvider );
            break;
            }
        case EChannelClosing:
            {
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - EChannelClosing" ) ) );
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() iChannelState = EChannelIdle" ) ) );
            
            iChannelState = EChannelIdle;
            if( iChannel )
                {
                iChannel->CloseChannel();
                delete iChannel;
                iChannel = NULL;
                }
            iSsyCallback->ChannelClosed( iChannelInfo.iChannelId );
            break;
            }
        case EChannelOpen:
            {
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - EChannelOpen" ) ) );
            break;
            }
        case EChannelListening:
            {
           
            break;
            }
        case EChannelStopListening:
            {
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - EChannelStopListening" ) ) );
            
           
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() iChannelState = EChannelOpen" ) ) );
            iChannelState = EChannelOpen;
            break;
            }
        case EChannelBufferFilled:
        case EChannelForceBufferFilled:
            {
             
            
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() - EChannelForceBufferFilled" ) ) );
            iSsyCallback->BufferFilled( iChannelInfo.iChannelId, iCounter, iDataBuffer, iMaxDataCount );
            iCounter = 0;
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() iChannelState = EChannelListening" ) ) );
            iChannelState = EChannelListening;
            IssueRequest();
            break;
            }
        default:
            {
            COMPONENT_TRACE( ( _L( "EventSsyStub - CEventChannel::RunL() unknown channel state" ) ) );
            }
        }

            
    }