source: cpp/frams/neuro/impl/neuroimpl-channels.cpp @ 120

Last change on this file since 120 was 109, checked in by sz, 11 years ago

source reorganization (see README)
new feature added: part/joint shapes (see frams/_demos/part_shapes.cpp)

  • Property svn:eol-style set to native
File size: 890 bytes
RevLine 
[109]1// This file is a part of the Framsticks GDK library.
2// Copyright (C) 2002-2011  Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
4
5#include "neuroimpl-channels.h"
6#include <common/nonstd_stl.h>
7
8void NI_Channelize::go()
9{
10setChannelCount(getInputCount());
11for(int i=0;i<getInputCount();i++)
12        setState(getWeightedInputState(i),i);
13}
14
15void NI_ChMux::go()
16{
17int c=getInputChannelCount(1);
18if (c<2) {setState(getWeightedInputState(1)); return;}
19double s=getWeightedInputState(0);
20s=(max(-1.0,min(1.0,s))+1.0)/2.0; // 0..1
21int i1;
22i1=(int)(s*(c-1)); i1=max(0,min(i1,c-2));
23double sw=1.0/(c-1);
24double s1=sw*i1;
25double w1=fabs((s-s1)/sw);
26double w2=1.0-w1;
27double is1=getWeightedInputState(1,i1);
28double is2=getWeightedInputState(1,i1+1);
29setState(is1*w2 + is2*w1);
30}
31
32void NI_ChSel::go()
33{
34setState(getWeightedInputState(0,ch));
35}
Note: See TracBrowser for help on using the repository browser.