Previous topic

SampleHold Block

Next topic

Sine Table Generator

This Page

The Table Module Block

constant Size { value: 1024 }

signal SineTable [Size] { default: 0.0 rate: none domain: AudioDomain }

Oscillator ( type: Sine frequency: 1.0 ) >> Table ( size: Size rate: Size ) >> SineTable;
module Table {
        input:                  Input
        output:                 Output
        propertyName:           [ 'size', 'rate' ]
        propertyDirection:      in
        propertyBlock:          [
                constant Size { value: 256 },
                constant Rate { value: Size }
        ]
        internalBlock:          [
                hybrid Input {
                        type:           [ 'Stream Real', 'Stream Integer', 'Constant Real', 'Constant Integer' ]
                        default:        [ 0.0, 0 ]
                        rate:           Rate
                        domain:         streamDomain
                },
                hybrid Output [Size] {
                        type:           [ 'Stream Real', 'Stream Integer' ]
                        default:        [ 0.0, 0 ]
                        rate:           none
                        domain:         streamDomain
                },
                reaction GenerateTable {
                        output:         Samples
                        terminateWhen:  Stop
                        internalBlock:  [
                                signal Index {
                                        default:        1
                                        rate:           Rate
                                        reset:          none
                                        domain:         streamDomain
                                },
                                signal Samples [Size] {
                                        default:        0.0
                                        rate:           none
                                        reset:          none
                                        domain:         streamDomain
                                },
                                switch Stop { default: off reset: none }
                        ]
                        streams:        [
                                Input >> Samples [Index];
                                Index + 1 >> Index >> Compare ( value: Size operator: 'Greater' ) >> Stop;
                        ]
                }
        ]
        streams:                GenerateTable () >> Output;
}