Boost logo

Boost :

Subject: Re: [boost] Flow-based programming library for Boost?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-01-04 09:53:41


Le 04/01/13 12:56, Marcus Tomlinson a écrit :
> On Fri, Jan 4, 2013 at 1:24 PM, Vicente J. Botet Escriba <
> vicente.botet_at_[hidden]> wrote:
>
>> Le 04/01/13 11:36, Marcus Tomlinson a écrit :
>>
>> On 04 Jan 2013, at 11:46 AM, "Vicente J. Botet Escriba" <
>>
>>
>> Could you show a simple example that makes use of this kind of changes?
>> BTW, what happens when you connect a char and you try to get/set an int or
>> a complex? Do you get an exception?
>
> Here's an example of the above vector<char> to a vector<int> situation
> (this component sets the gain of the audio signal passing through it):
>
> virtual void Process_( DspSignalBus& inputs, DspSignalBus& outputs )
> {
>
> // Audio input of char samples
>
> std::vector< char > _charStream;
> if( inputs.GetValue( 0, _charStream ) )
> {
> for( unsigned long i = 0; i < _charStream.size(); i++ )
> {
> _charStream[i] *= _gain;
> }
> outputs.SetValue( 0, _charStream );
> }
>
> // Audio input of int samples
>
> std::vector< int > _intStream;
> else if( inputs.GetValue( 0, _intStream ) )
> {
> for( unsigned long i = 0; i < _intStream.size(); i++ )
> {
> _intStream[i] *= _gain;
> }
> outputs.SetValue( 0, _intStream );
> }
>
> }
>
> The GetValue() and SetValue() methods simply return false if the type
> you're trying to get/set is mismatched. We use this in order to determine
> what data we have received.
>
Couldn't this signal (if it is a single one) be split on two signals
towards two specific components?
Or, couldn't a signal with type boost::variant<std::vector<char>,
std::vector<int>> be used instead?

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk