Last change
on this file was
1130,
checked in by Maciej Komosinski, 4 years ago
|
Used std::min(), std::max() explicitly to avoid compiler confusion. Used std::size() explicitly instead of the equivalent macro
|
-
Property svn:eol-style set to
native
|
File size:
962 bytes
|
Rev | Line | |
---|
[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
[1130] | 2 | // Copyright (C) 1999-2021 Maciej Komosinski and Szymon Ulatowski. |
---|
[286] | 3 | // See LICENSE.txt for details. |
---|
[109] | 4 | |
---|
| 5 | #include "neuroimpl-channels.h" |
---|
[1130] | 6 | #include <algorithm> |
---|
[109] | 7 | |
---|
| 8 | void NI_Channelize::go() |
---|
| 9 | { |
---|
[791] | 10 | setChannelCount(getInputCount()); |
---|
| 11 | for (int i = 0; i < getInputCount(); i++) |
---|
| 12 | setState(getWeightedInputState(i), i); |
---|
[109] | 13 | } |
---|
| 14 | |
---|
| 15 | void NI_ChMux::go() |
---|
| 16 | { |
---|
[791] | 17 | int c = getInputChannelCount(1); |
---|
| 18 | if (c < 2) { setState(getWeightedInputState(1)); return; } |
---|
| 19 | double s = getWeightedInputState(0); |
---|
[1130] | 20 | s = (std::max(-1.0, std::min(1.0, s)) + 1.0) / 2.0; // 0..1 |
---|
[791] | 21 | int i1; |
---|
[1130] | 22 | i1 = (int)(s * (c - 1)); i1 = std::max(0, std::min(i1, c - 2)); |
---|
[791] | 23 | double sw = 1.0 / (c - 1); |
---|
[907] | 24 | double s1 = sw * i1; |
---|
[791] | 25 | double w1 = fabs((s - s1) / sw); |
---|
| 26 | double w2 = 1.0 - w1; |
---|
| 27 | double is1 = getWeightedInputState(1, i1); |
---|
| 28 | double is2 = getWeightedInputState(1, i1 + 1); |
---|
[907] | 29 | setState(is1 * w2 + is2 * w1); |
---|
[109] | 30 | } |
---|
| 31 | |
---|
| 32 | void NI_ChSel::go() |
---|
| 33 | { |
---|
[791] | 34 | setState(getWeightedInputState(0, ch)); |
---|
[109] | 35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.