Revision 5:75b744078d66 CollidoscopeApp/include
| CollidoscopeApp/include/AudioEngine.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include <array> |
| CollidoscopeApp/include/BufferToWaveRecorderNode.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
|
|
| 21 |
This file incorporates work covered by the following copyright and permission notice: |
|
| 22 |
|
|
| 23 |
Copyright (c) 2014, The Cinder Project |
|
| 24 |
|
|
| 25 |
This code is intended to be used with the Cinder C++ library, http://libcinder.org |
|
| 26 |
|
|
| 27 |
Redistribution and use in source and binary forms, with or without modification, are permitted provided that |
|
| 28 |
the following conditions are met: |
|
| 29 |
|
|
| 30 |
* Redistributions of source code must retain the above copyright notice, this list of conditions and |
|
| 31 |
the following disclaimer. |
|
| 32 |
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and |
|
| 33 |
the following disclaimer in the documentation and/or other materials provided with the distribution. |
|
| 34 |
|
|
| 35 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED |
|
| 36 |
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
|
| 37 |
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
|
| 38 |
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
|
| 39 |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
| 40 |
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
| 41 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
| 42 |
POSSIBILITY OF SUCH DAMAGE. |
|
| 43 |
|
|
| 44 |
*/ |
|
| 45 |
|
|
| 1 | 46 |
#pragma once |
| 2 | 47 |
|
| 3 | 48 |
#include "cinder/Cinder.h" |
| ... | ... | |
| 8 | 53 |
|
| 9 | 54 |
#include "Messages.h" |
| 10 | 55 |
|
| 11 |
typedef std::shared_ptr<class BufferToWaveRecorderNode> BufferToWaveRecorderNodeRef;
|
|
| 56 |
typedef std::shared_ptr<class BufferToWaveRecorderNode> BufferToWaveRecorderNodeRef;
|
|
| 12 | 57 |
|
| 13 | 58 |
typedef ci::audio::dsp::RingBufferT<RecordWaveMsg> RecordWaveMsgRingBuffer; |
| 14 | 59 |
|
| ... | ... | |
| 43 | 88 |
void setNumSeconds(double numSeconds, bool shrinkToFit = false); |
| 44 | 89 |
|
| 45 | 90 |
//! Returns the length of the recording buffer in frames. |
| 46 |
size_t getNumFrames() const { return mRecorderBuffer.getNumFrames(); }
|
|
| 91 |
size_t getNumFrames() const { return mRecorderBuffer.getNumFrames(); }
|
|
| 47 | 92 |
//! Returns the length of the recording buffer in seconds. |
| 48 |
double getNumSeconds() const;
|
|
| 93 |
double getNumSeconds() const;
|
|
| 49 | 94 |
|
| 50 | 95 |
//! \brief Returns a copy of the recored samples, up to the current write position. |
| 51 | 96 |
//! |
| 52 | 97 |
//! This method is non locking, and as such any resizing calls must be performed on the same thread or be otherwise synchronized. |
| 53 |
ci::audio::BufferRef getRecordedCopy() const;
|
|
| 98 |
ci::audio::BufferRef getRecordedCopy() const;
|
|
| 54 | 99 |
|
| 55 | 100 |
//! \brief Writes the currently recorded samples to a file at \a filePath |
| 56 | 101 |
//! |
| ... | ... | |
| 69 | 114 |
|
| 70 | 115 |
|
| 71 | 116 |
protected: |
| 72 |
void initialize() override;
|
|
| 73 |
void process(ci::audio::Buffer *buffer) override;
|
|
| 117 |
void initialize() override;
|
|
| 118 |
void process(ci::audio::Buffer *buffer) override;
|
|
| 74 | 119 |
|
| 75 | 120 |
void initBuffers(size_t numFrames); |
| 76 | 121 |
|
| 77 | 122 |
static const float kMinAudioVal; |
| 78 | 123 |
static const float kMaxAudioVal; |
| 79 | 124 |
|
| 80 |
ci::audio::BufferDynamic mRecorderBuffer;
|
|
| 81 |
ci::audio::BufferDynamicRef mCopiedBuffer;
|
|
| 82 |
std::atomic<uint64_t> mLastOverrun;
|
|
| 125 |
ci::audio::BufferDynamic mRecorderBuffer;
|
|
| 126 |
ci::audio::BufferDynamicRef mCopiedBuffer;
|
|
| 127 |
std::atomic<uint64_t> mLastOverrun;
|
|
| 83 | 128 |
|
| 84 | 129 |
RecordWaveMsgRingBuffer mRingBuffer; |
| 85 | 130 |
|
| CollidoscopeApp/include/Chunk.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2015 Fiore Martin |
|
| 4 |
Copyright (C) 2016 Queen Mary University of London |
|
| 5 |
Author: Fiore Martin |
|
| 6 |
|
|
| 7 |
This file is part of Collidoscope. |
|
| 8 |
|
|
| 9 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 10 |
it under the terms of the GNU General Public License as published by |
|
| 11 |
the Free Software Foundation, either version 3 of the License, or |
|
| 12 |
(at your option) any later version. |
|
| 13 |
|
|
| 14 |
This program is distributed in the hope that it will be useful, |
|
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
GNU General Public License for more details. |
|
| 18 |
|
|
| 19 |
You should have received a copy of the GNU General Public License |
|
| 20 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
|
|
| 22 |
*/ |
|
| 23 |
|
|
| 1 | 24 |
|
| 2 | 25 |
#pragma once |
| 3 | 26 |
|
| ... | ... | |
| 26 | 49 |
/** |
| 27 | 50 |
* Constructor, takes as argument the index of this chunk in the wave |
| 28 | 51 |
*/ |
| 29 |
Chunk( size_t index );
|
|
| 52 |
Chunk( size_t index );
|
|
| 30 | 53 |
|
| 31 | 54 |
/** |
| 32 | 55 |
* Sets the top value of this chunk. The value is passed in audio coordinates : [-1.0, 1.0] |
| ... | ... | |
| 49 | 72 |
* Reset this chunks. When a chunk is reset it starts shrinking until it disappears. |
| 50 | 73 |
* |
| 51 | 74 |
*/ |
| 52 |
void reset(){
|
|
| 53 |
mResetting = true;
|
|
| 54 |
}
|
|
| 75 |
void reset(){
|
|
| 76 |
mResetting = true;
|
|
| 77 |
}
|
|
| 55 | 78 |
|
| 56 | 79 |
/** |
| 57 | 80 |
* Called in the graphic loop. It update this chunk. |
| ... | ... | |
| 72 | 95 |
/** |
| 73 | 96 |
* Informs this chunk that it's the first chunk of the selection. |
| 74 | 97 |
*/ |
| 75 |
void setAsSelectionStart(bool start){
|
|
| 76 |
isSelectionStart = start;
|
|
| 77 |
}
|
|
| 98 |
void setAsSelectionStart(bool start){
|
|
| 99 |
isSelectionStart = start;
|
|
| 100 |
}
|
|
| 78 | 101 |
|
| 79 | 102 |
/** |
| 80 | 103 |
* Informs this chunk that it's the last chunk of the selection. |
| 81 | 104 |
*/ |
| 82 |
void setAsSelectionEnd(bool end){
|
|
| 83 |
isSelectionEnd = end;
|
|
| 84 |
}
|
|
| 105 |
void setAsSelectionEnd(bool end){
|
|
| 106 |
isSelectionEnd = end;
|
|
| 107 |
}
|
|
| 85 | 108 |
|
| 86 | 109 |
private: |
| 87 | 110 |
|
| CollidoscopeApp/include/Config.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include <string> |
| CollidoscopeApp/include/DrawInfo.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include "cinder/Area.h" |
| ... | ... | |
| 40 | 61 |
* Maps a value in the audio space [-1.0, 1.0] to a position on the y axis of this DrawInf's bounding area. |
| 41 | 62 |
* |
| 42 | 63 |
*/ |
| 43 |
float audioToHeigt(float audioSample) const {
|
|
| 64 |
float audioToHeigt(float audioSample) const {
|
|
| 44 | 65 |
/* clip into range [-1.1] */ |
| 45 | 66 |
if (audioSample < -1.0f) {
|
| 46 | 67 |
audioSample = -1.0f; |
| ... | ... | |
| 50 | 71 |
} |
| 51 | 72 |
|
| 52 | 73 |
/* map from [-1,1] to [0,1] */ |
| 53 |
float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1)
|
|
| 74 |
float ratio = (audioSample - (-1.0f)) * 0.5f; // 2 = 1 - (-1)
|
|
| 54 | 75 |
|
| 55 |
/* get bottom and add the scaled height */
|
|
| 76 |
/* get bottom and add the scaled height */
|
|
| 56 | 77 |
return ratio * mSelectionBarHeight; //remove bounds.getY1() bound only needed for size of tier |
| 57 |
}
|
|
| 78 |
}
|
|
| 58 | 79 |
|
| 59 | 80 |
float getMaxChunkHeight() const |
| 60 | 81 |
{
|
| ... | ... | |
| 80 | 101 |
/** |
| 81 | 102 |
* Flips y according to the index of the wave. It is needed because the second wave in collidoscope is upside down from the orientation oftthe screen. |
| 82 | 103 |
*/ |
| 83 |
int flipY(int y) const
|
|
| 104 |
int flipY(int y) const
|
|
| 84 | 105 |
{
|
| 85 | 106 |
if ( mWaveIndex == 0) |
| 86 |
return mWindowHeight - y;
|
|
| 107 |
return mWindowHeight - y;
|
|
| 87 | 108 |
else |
| 88 | 109 |
return y; |
| 89 |
}
|
|
| 110 |
}
|
|
| 90 | 111 |
|
| 91 | 112 |
/** |
| 92 | 113 |
* Returns x. not used at he moment. |
| 93 | 114 |
* |
| 94 | 115 |
*/ |
| 95 |
int flipX(int x) const
|
|
| 116 |
int flipX(int x) const
|
|
| 96 | 117 |
{
|
| 97 | 118 |
return x; |
| 98 |
}
|
|
| 119 |
}
|
|
| 99 | 120 |
|
| 100 | 121 |
|
| 101 | 122 |
// how much the wave is shrunk on the y axis with respect to the wave's tier |
| CollidoscopeApp/include/EnvASR.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
namespace collidoscope {
|
| CollidoscopeApp/include/Log.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
|
| CollidoscopeApp/include/MIDI.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include "RtMidi.h" |
| CollidoscopeApp/include/Messages.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
/** |
| CollidoscopeApp/include/Oscilloscope.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include "cinder/gl/gl.h" |
| CollidoscopeApp/include/PGranular.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include <array> |
| CollidoscopeApp/include/PGranularNode.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include "cinder/Cinder.h" |
| ... | ... | |
| 54 | 75 |
|
| 55 | 76 |
protected: |
| 56 | 77 |
|
| 57 |
void initialize() override;
|
|
| 78 |
void initialize() override;
|
|
| 58 | 79 |
|
| 59 |
void process( ci::audio::Buffer *buffer ) override;
|
|
| 80 |
void process( ci::audio::Buffer *buffer ) override;
|
|
| 60 | 81 |
|
| 61 | 82 |
private: |
| 62 | 83 |
|
| CollidoscopeApp/include/ParticleController.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2015 Fiore Martin |
|
| 4 |
Copyright (C) 2016 Queen Mary University of London |
|
| 5 |
Author: Fiore Martin |
|
| 6 |
|
|
| 7 |
This file is part of Collidoscope. |
|
| 8 |
|
|
| 9 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 10 |
it under the terms of the GNU General Public License as published by |
|
| 11 |
the Free Software Foundation, either version 3 of the License, or |
|
| 12 |
(at your option) any later version. |
|
| 13 |
|
|
| 14 |
This program is distributed in the hope that it will be useful, |
|
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
GNU General Public License for more details. |
|
| 18 |
|
|
| 19 |
You should have received a copy of the GNU General Public License |
|
| 20 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
|
|
| 22 |
*/ |
|
| 23 |
|
|
| 1 | 24 |
#pragma once |
| 2 | 25 |
|
| 3 | 26 |
#include "cinder/gl/gl.h" |
| CollidoscopeApp/include/Resources.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
#include "cinder/CinderResources.h" |
| 3 | 24 |
|
| CollidoscopeApp/include/RingBufferPack.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2016 Queen Mary University of London |
|
| 4 |
Author: Fiore Martin |
|
| 5 |
|
|
| 6 |
This file is part of Collidoscope. |
|
| 7 |
|
|
| 8 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 9 |
it under the terms of the GNU General Public License as published by |
|
| 10 |
the Free Software Foundation, either version 3 of the License, or |
|
| 11 |
(at your option) any later version. |
|
| 12 |
|
|
| 13 |
This program is distributed in the hope that it will be useful, |
|
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 16 |
GNU General Public License for more details. |
|
| 17 |
|
|
| 18 |
You should have received a copy of the GNU General Public License |
|
| 19 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 20 |
*/ |
|
| 21 |
|
|
| 1 | 22 |
#pragma once |
| 2 | 23 |
|
| 3 | 24 |
#include "cinder/audio/dsp/RingBuffer.h" |
| CollidoscopeApp/include/Wave.h | ||
|---|---|---|
| 1 |
/* |
|
| 2 |
|
|
| 3 |
Copyright (C) 2015 Fiore Martin |
|
| 4 |
Copyright (C) 2016 Queen Mary University of London |
|
| 5 |
Author: Fiore Martin |
|
| 6 |
|
|
| 7 |
This file is part of Collidoscope. |
|
| 8 |
|
|
| 9 |
Collidoscope is free software: you can redistribute it and/or modify |
|
| 10 |
it under the terms of the GNU General Public License as published by |
|
| 11 |
the Free Software Foundation, either version 3 of the License, or |
|
| 12 |
(at your option) any later version. |
|
| 13 |
|
|
| 14 |
This program is distributed in the hope that it will be useful, |
|
| 15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 17 |
GNU General Public License for more details. |
|
| 18 |
|
|
| 19 |
You should have received a copy of the GNU General Public License |
|
| 20 |
along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
| 21 |
|
|
| 22 |
*/ |
|
| 1 | 23 |
#pragma once |
| 2 | 24 |
|
| 3 | 25 |
|
| ... | ... | |
| 45 | 67 |
*/ |
| 46 | 68 |
class Wave |
| 47 | 69 |
{
|
| 48 |
friend class ParticleController;
|
|
| 70 |
friend class ParticleController;
|
|
| 49 | 71 |
|
| 50 | 72 |
public: |
| 51 | 73 |
|
| ... | ... | |
| 53 | 75 |
* The selection of the wave that is controlled by the big horizontal knob |
| 54 | 76 |
* |
| 55 | 77 |
*/ |
| 56 |
class Selection {
|
|
| 57 |
|
|
| 58 |
public:
|
|
| 78 |
class Selection {
|
|
| 79 |
|
|
| 80 |
public:
|
|
| 59 | 81 |
|
| 60 | 82 |
Selection( Wave * w, Color color ); |
| 61 | 83 |
|
| ... | ... | |
| 63 | 85 |
void setStart( size_t start ); |
| 64 | 86 |
|
| 65 | 87 |
/** Sets the size of selection. size is the number of chunks the selection is made of */ |
| 66 |
void setSize( size_t size );
|
|
| 67 |
|
|
| 88 |
void setSize( size_t size );
|
|
| 89 |
|
|
| 68 | 90 |
/** Particle spread is used to calculate the size of the cloud of particles */ |
| 69 | 91 |
void inline setParticleSpread( float spread ){
|
| 70 | 92 |
mParticleSpread = spread; |
| 71 |
}
|
|
| 93 |
}
|
|
| 72 | 94 |
|
| 73 |
size_t getStart(void) const { return mSelectionStart; }
|
|
| 74 |
|
|
| 95 |
size_t getStart(void) const { return mSelectionStart; }
|
|
| 96 |
|
|
| 75 | 97 |
size_t getEnd(void) const { return mSelectionEnd; }
|
| 76 | 98 |
|
| 77 |
size_t inline getSize(void) const {
|
|
| 78 |
if (mNull)
|
|
| 79 |
return 0;
|
|
| 80 |
else
|
|
| 81 |
return 1 + mSelectionEnd - mSelectionStart;
|
|
| 82 |
}
|
|
| 99 |
size_t inline getSize(void) const {
|
|
| 100 |
if (mNull)
|
|
| 101 |
return 0;
|
|
| 102 |
else
|
|
| 103 |
return 1 + mSelectionEnd - mSelectionStart;
|
|
| 104 |
}
|
|
| 83 | 105 |
|
| 84 |
float inline getParticleSpread() const { return mParticleSpread; }
|
|
| 106 |
float inline getParticleSpread() const { return mParticleSpread; }
|
|
| 85 | 107 |
|
| 86 | 108 |
/** When selection is null no selection is showed on the wave */ |
| 87 |
inline void setToNull(){
|
|
| 109 |
inline void setToNull(){
|
|
| 88 | 110 |
mParticleSpread = 1.0f; |
| 89 |
mNull = true;
|
|
| 90 |
}
|
|
| 111 |
mNull = true;
|
|
| 112 |
}
|
|
| 91 | 113 |
|
| 92 |
inline bool isNull() const{
|
|
| 93 |
return mNull;
|
|
| 94 |
}
|
|
| 114 |
inline bool isNull() const{
|
|
| 115 |
return mNull;
|
|
| 116 |
}
|
|
| 95 | 117 |
|
| 96 |
inline const Color & getColor() const{
|
|
| 97 |
return mColor;
|
|
| 98 |
}
|
|
| 118 |
inline const Color & getColor() const{
|
|
| 119 |
return mColor;
|
|
| 120 |
}
|
|
| 99 | 121 |
|
| 100 | 122 |
private: |
| 101 | 123 |
|
| ... | ... | |
| 111 | 133 |
|
| 112 | 134 |
Wave * mWave; |
| 113 | 135 |
|
| 114 |
}; // class Selection
|
|
| 136 |
}; // class Selection
|
|
| 115 | 137 |
|
| 116 |
|
|
| 138 |
|
|
| 117 | 139 |
|
| 118 | 140 |
#ifdef USE_PARTICLES |
| 119 |
ParticleController mParticleController;
|
|
| 141 |
ParticleController mParticleController;
|
|
| 120 | 142 |
#endif |
| 121 | 143 |
|
| 122 |
|
|
| 144 |
|
|
| 123 | 145 |
|
| 124 |
/* Maps id of the synth to cursor. There is one cursor for each Synth being played */
|
|
| 125 |
std::map < SynthID, Cursor > mCursors;
|
|
| 146 |
/* Maps id of the synth to cursor. There is one cursor for each Synth being played */
|
|
| 147 |
std::map < SynthID, Cursor > mCursors;
|
|
| 126 | 148 |
/** Holds the positions of the cursor, namely on which chunk the cursor is currently */ |
| 127 |
std::vector<int> mCursorsPos;
|
|
| 149 |
std::vector<int> mCursorsPos;
|
|
| 128 | 150 |
|
| 129 | 151 |
public: |
| 130 |
|
|
| 152 |
|
|
| 131 | 153 |
// value used to identify the loop for cursor position |
| 132 | 154 |
static const int kLoopNote = -1; |
| 133 |
static const cinder::Color CURSOR_CLR;
|
|
| 134 |
/* must be in sync with supercollider durationFactor ControlSpec max */
|
|
| 135 |
static const int MAX_DURATION = 8;
|
|
| 155 |
static const cinder::Color CURSOR_CLR;
|
|
| 156 |
/* must be in sync with supercollider durationFactor ControlSpec max */
|
|
| 157 |
static const int MAX_DURATION = 8;
|
|
| 136 | 158 |
#ifdef USE_PARTICLES |
| 137 |
static const int PARTICLESIZE_COEFF = 40;
|
|
| 159 |
static const int PARTICLESIZE_COEFF = 40;
|
|
| 138 | 160 |
#endif |
| 139 | 161 |
|
| 140 | 162 |
/** Resetting a wave makes it shrink until it disappears. Each time a new sample is recorder the wave is reset |
| 141 | 163 |
* \param onlyChunks if false the selection is also set to null, if true only the chunks are reset |
| 142 | 164 |
*/ |
| 143 |
void reset(bool onlyChunks);
|
|
| 165 |
void reset(bool onlyChunks);
|
|
| 144 | 166 |
|
| 145 | 167 |
/** sets top and bottom values for the chunk. |
| 146 | 168 |
* \a bottom and \a top are in audio coordinates [-1.0, 1.0] |
| 147 | 169 |
*/ |
| 148 |
void setChunk(size_t index, float bottom, float top);
|
|
| 170 |
void setChunk(size_t index, float bottom, float top);
|
|
| 149 | 171 |
|
| 150 |
const Chunk & getChunk(size_t index);
|
|
| 172 |
const Chunk & getChunk(size_t index);
|
|
| 151 | 173 |
|
| 152 | 174 |
/** places the cursor on the wave. Every cursor is associated to a synth voice of the audio engine. |
| 153 | 175 |
* The synth id identifies uniquely the cursor in the internal map of the wave. |
| 154 | 176 |
* If the cursor doesn't exist it is created */ |
| 155 | 177 |
inline void setCursorPos( SynthID id, int pos, const DrawInfo& di ){
|
| 156 | 178 |
|
| 157 |
Cursor & cursor = mCursors[id];
|
|
| 158 |
cursor.pos = pos;
|
|
| 159 |
cursor.lastUpdate = ci::app::getElapsedSeconds();
|
|
| 179 |
Cursor & cursor = mCursors[id];
|
|
| 180 |
cursor.pos = pos;
|
|
| 181 |
cursor.lastUpdate = ci::app::getElapsedSeconds();
|
|
| 160 | 182 |
|
| 161 | 183 |
#ifdef USE_PARTICLES |
| 162 |
// The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles
|
|
| 163 |
// The smaller the selection the more particles; the bigger the duration the more particles
|
|
| 164 |
if (mSelection.getParticleSpread() > 1.0f){
|
|
| 165 |
/* amountCoeff ranges from 1/8 to 1 */
|
|
| 184 |
// The idea is that, if the duration is greater than 1.0, the cursor continues in form of particles
|
|
| 185 |
// The smaller the selection the more particles; the bigger the duration the more particles
|
|
| 186 |
if (mSelection.getParticleSpread() > 1.0f){
|
|
| 187 |
/* amountCoeff ranges from 1/8 to 1 */
|
|
| 166 | 188 |
const float amountCoeff = (mSelection.getParticleSpread() / MAX_DURATION); |
| 167 | 189 |
|
| 168 | 190 |
/* get radom point within seleciton as center of the particle */ |
| ... | ... | |
| 173 | 195 |
centrePoint.y = di.flipY( di.audioToHeigt(0.0) ); |
| 174 | 196 |
|
| 175 | 197 |
const float wavePixelLen = mNumChunks * ( 2 + Chunk::kWidth); |
| 176 |
centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
|
|
| 198 |
centrePoint.x *= float(di.getWindowWidth()) / wavePixelLen;
|
|
| 177 | 199 |
|
| 178 |
mParticleController.addParticles(
|
|
| 200 |
mParticleController.addParticles(
|
|
| 179 | 201 |
std::max( 1, (int)(amountCoeff * ParticleController::kMaxParticleAdd * mFilterCoeff) ), // amount of particles to add |
| 180 |
centrePoint,
|
|
| 202 |
centrePoint,
|
|
| 181 | 203 |
mSelection.getParticleSpread() * PARTICLESIZE_COEFF // size of the cloud |
| 182 |
);
|
|
| 183 |
}
|
|
| 204 |
);
|
|
| 205 |
}
|
|
| 184 | 206 |
#endif |
| 185 | 207 |
|
| 186 |
|
|
| 187 |
}
|
|
| 208 |
|
|
| 209 |
}
|
|
| 188 | 210 |
|
| 189 | 211 |
void update( double secondsPerChunk, const DrawInfo& di ); |
| 190 | 212 |
|
| 191 | 213 |
void removeCursor( SynthID id ) { mCursors.erase( id ); }
|
| 192 | 214 |
|
| 193 | 215 |
/** Sets the transparency of this wave. \a alpha ranges from 0 to 1 */ |
| 194 |
inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
|
|
| 216 |
inline void setselectionAlpha(float alpha){ mFilterCoeff = alpha;}
|
|
| 195 | 217 |
|
| 196 | 218 |
void draw( const DrawInfo& di ); |
| 197 | 219 |
|
| 198 |
Selection& getSelection() { return mSelection; };
|
|
| 220 |
Selection& getSelection() { return mSelection; };
|
|
| 199 | 221 |
|
| 200 |
size_t getSize() const{ return mChunks.size(); }
|
|
| 222 |
size_t getSize() const{ return mChunks.size(); }
|
|
| 201 | 223 |
|
| 202 |
void setScopePoint(int index, float audioVal);
|
|
| 224 |
void setScopePoint(int index, float audioVal);
|
|
| 203 | 225 |
|
| 204 | 226 |
Wave( size_t numChunks, Color selectionColor ); |
| 205 | 227 |
|
Also available in: Unified diff