|
| 1 | +% (C) Copyright 2021 CPP LePoulpe developers |
| 2 | + |
| 3 | +% This demo presents auditory or visual motion on LePoulpe. |
| 4 | +% It generates sound noises (white, pink, brown noise) in a given length and |
| 5 | +% cuts the sound array into chunks to play each chunk in a speaker. |
| 6 | +% |
| 7 | +% For visual motion it activates LEDs in a given speed, plane (horizontal, |
| 8 | +% vertical). |
| 9 | + |
| 10 | +run(fullfile('..', 'initLePoulpe.m')); |
| 11 | + |
| 12 | +pacedByUser = false; |
| 13 | + |
| 14 | +waitForAWhile = 0; |
| 15 | + |
| 16 | +%% set cfg for LEDs |
| 17 | +speed = .03; |
| 18 | +nbRepetitionLED = 1; |
| 19 | + |
| 20 | +%% set cfg for sounds |
| 21 | +fs = 44100; |
| 22 | +saveAsWav = 1; |
| 23 | +duration = 0.8; |
| 24 | +nbRepetitionSound = 2; |
| 25 | +waitForSwtich = 1; |
| 26 | + |
| 27 | +% outSound = generateNoise('white', duration, saveAsWav, fs); |
| 28 | +outSound = generateNoise('pink', duration, saveAsWav, fs); |
| 29 | + |
| 30 | +nbSpeakers = 31; |
| 31 | + |
| 32 | +% [soundArray] = cutSoundArray(inputSound, inputName, fs, nbSpeakers, saveAsWav); |
| 33 | +[soundArray] = cutSoundArray(outSound, 'pinknoise', fs, nbSpeakers, saveAsWav); |
| 34 | + |
| 35 | + |
| 36 | +% build the speaker arrays for each direction |
| 37 | +speakerIdxRightward = generateMotionSpeakerArray('rightward'); |
| 38 | + |
| 39 | +speakerIdxLeftward = generateMotionSpeakerArray('leftward'); |
| 40 | + |
| 41 | +speakerIdxDownward = generateMotionSpeakerArray('downward'); |
| 42 | + |
| 43 | +speakerIdxUpward = generateMotionSpeakerArray('upward'); |
| 44 | + |
| 45 | +%% play sounds (auditory motion) |
| 46 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 47 | + |
| 48 | +playMotionSound('horizontal', ... |
| 49 | + speakerIdxRightward, ... |
| 50 | + soundArray, ... |
| 51 | + nbRepetitionSound, ... |
| 52 | + waitForSwtich); |
| 53 | + |
| 54 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 55 | + |
| 56 | +playMotionSound('horizontal', ... |
| 57 | + speakerIdxLeftward, ... |
| 58 | + soundArray, ... |
| 59 | + nbRepetitionSound, ... |
| 60 | + waitForSwtich); |
| 61 | + |
| 62 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 63 | + |
| 64 | +playMotionSound('vertical', ... |
| 65 | + speakerIdxDownward, ... |
| 66 | + soundArray, ... |
| 67 | + nbRepetitionSound, ... |
| 68 | + waitForSwtich); |
| 69 | + |
| 70 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 71 | + |
| 72 | +playMotionSound('vertical', ... |
| 73 | + speakerIdxUpward, ... |
| 74 | + soundArray, ... |
| 75 | + nbRepetitionSound, ... |
| 76 | + waitForSwtich); |
| 77 | + |
| 78 | + %% play LEDs (visual motion) |
| 79 | + |
| 80 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 81 | + |
| 82 | +playVisualMotion('rightward', ... |
| 83 | + speed, ... |
| 84 | + 2, ... |
| 85 | + nbRepetitionLED); |
| 86 | + |
| 87 | + |
| 88 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 89 | + |
| 90 | +playVisualMotion('leftward', ... |
| 91 | + speed, ... |
| 92 | + 2, ... |
| 93 | + nbRepetitionLED) |
| 94 | + |
| 95 | + |
| 96 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 97 | + |
| 98 | +playVisualMotion('downward', ... |
| 99 | + speed, ... |
| 100 | + 1, ... |
| 101 | + nbRepetitionLED) |
| 102 | + |
| 103 | + |
| 104 | +pressSpaceForMeOrWait(pacedByUser, waitForAWhile) |
| 105 | + |
| 106 | +playVisualMotion('upward', ... |
| 107 | + speed, ... |
| 108 | + 1, ... |
| 109 | + nbRepetitionLED) |
0 commit comments