id
int64 0
755k
| file_name
stringlengths 3
109
| file_path
stringlengths 13
185
| content
stringlengths 31
9.38M
| size
int64 31
9.38M
| language
stringclasses 1
value | extension
stringclasses 11
values | total_lines
int64 1
340k
| avg_line_length
float64 2.18
149k
| max_line_length
int64 7
2.22M
| alphanum_fraction
float64 0
1
| repo_name
stringlengths 6
65
| repo_stars
int64 100
47.3k
| repo_forks
int64 0
12k
| repo_open_issues
int64 0
3.4k
| repo_license
stringclasses 9
values | repo_extraction_date
stringclasses 92
values | exact_duplicates_redpajama
bool 2
classes | near_duplicates_redpajama
bool 2
classes | exact_duplicates_githubcode
bool 2
classes | exact_duplicates_stackv2
bool 1
class | exact_duplicates_stackv1
bool 2
classes | near_duplicates_githubcode
bool 2
classes | near_duplicates_stackv1
bool 2
classes | near_duplicates_stackv2
bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
754,541
|
KiwiEngine_Gate.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Gate.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// GATE //
// ================================================================================ //
class Gate : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Gate(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override;
private:
void openOutput(int output);
private:
size_t m_opened_output;
size_t m_num_outputs;
};
}}
| 1,774
|
C++
|
.h
| 34
| 45.088235
| 93
| 0.501832
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,542
|
KiwiEngine_Unpack.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Unpack.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// UNPACK //
// ================================================================================ //
class Unpack : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Unpack(model::Object const& model, Patcher& patcher);
~Unpack() = default;
void receive(size_t index, std::vector<tool::Atom> const& args) override;
void output_list();
private:
std::vector<tool::Atom> m_list;
};
}}
| 1,763
|
C++
|
.h
| 33
| 46.272727
| 93
| 0.499386
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,543
|
KiwiEngine_DifferentTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_DifferentTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// !=~ //
// ================================================================================ //
class DifferentTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
DifferentTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,681
|
C++
|
.h
| 29
| 52.310345
| 97
| 0.507547
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,544
|
KiwiEngine_SwitchTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_SwitchTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiDsp/KiwiDsp_Signal.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SWITCH~ //
// ================================================================================ //
class SwitchTilde : public AudioObject
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
SwitchTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void prepare(PrepareInfo const& infos) override final;
void performValue(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performSig(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
private:
void openInput(int input);
private:
size_t m_opened_input;
size_t m_num_inputs;
};
}}
| 2,078
|
C++
|
.h
| 38
| 46.868421
| 93
| 0.536649
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,545
|
KiwiEngine_Bang.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Bang.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT BANG //
// ================================================================================ //
class Bang : public engine::Object
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& object, Patcher & patcher);
Bang(model::Object const& model, Patcher& patcher);
~Bang();
void signalTriggered();
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
private: // members
flip::Signal<>& m_trigger_signal;
flip::Signal<>& m_flash_signal;
flip::SignalConnection m_connection;
};
}}
| 1,880
|
C++
|
.h
| 35
| 46.571429
| 94
| 0.50601
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,546
|
KiwiEngine_Pipe.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Pipe.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT PIPE //
// ================================================================================ //
class Pipe final : public engine::Object
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Pipe(model::Object const& model, Patcher& patcher);
~Pipe();
void receive(size_t index, std::vector<tool::Atom> const& args) override;
private: // members
tool::Scheduler<>::clock_t::duration m_delay;
};
}}
| 1,757
|
C++
|
.h
| 32
| 48.09375
| 93
| 0.502451
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,547
|
KiwiEngine_Slider.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Slider.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <vector>
#include <memory>
#include <KiwiTool/KiwiTool_Atom.h>
#include <KiwiTool/KiwiTool_Parameter.h>
#include <KiwiModel/KiwiModel_Object.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT SLIDER //
// ================================================================================ //
class Slider : public engine::Object
{
public: // methods
Slider(model::Object const& model, Patcher& patcher);
~Slider();
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
private: // methods
void outputValue();
private: // members
double m_value;
flip::SignalConnection m_connection;
};
}}
| 2,110
|
C++
|
.h
| 41
| 44.902439
| 100
| 0.540265
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,548
|
KiwiEngine_Receive.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Receive.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Beacon.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT RECEIVE //
// ================================================================================ //
class Receive : public engine::Object, public tool::Beacon::Castaway
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
Receive(model::Object const& model, Patcher& patcher);
~Receive();
//! @brief inlets receive.
void receive(size_t, std::vector<tool::Atom> const& args) override;
//! @brief beacon receive.
void receive(std::vector<tool::Atom> const& args) override;
private: // members
std::string m_name;
};
}}
| 1,959
|
C++
|
.h
| 36
| 47.305556
| 92
| 0.515385
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,549
|
KiwiEngine_SfPlayTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_SfPlayTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
#include <juce_core/juce_core.h>
#include <juce_audio_formats/juce_audio_formats.h>
#include <juce_audio_devices/juce_audio_devices.h>
#include <juce_gui_basics/juce_gui_basics.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SOUNDFILE PLAYER //
// ================================================================================ //
class SoundFilePlayer
: public juce::ChangeListener
{
public: // methods
SoundFilePlayer();
~SoundFilePlayer();
//! @brief Starts reading file from start pos to end pos.
//! @details if end time is greater than starting time,
//! file will be played from the start position to the end of the file
bool start(const juce::File& file, double start_ms = 0., double end_ms = -1.);
void stop();
bool isPlaying() const;
void setLoop(bool should_loop);
void setNumberOfChannels(size_t channels);
size_t getNumberOfChannels() const;
juce::String getSupportedFormats() const;
void prepare(double sample_rate, size_t vector_size);
bool read(dsp::Buffer& input);
void release();
using playingStoppedCallback = std::function<void(void)>;
void setPlayingStoppedCallback(playingStoppedCallback && fn);
//! @brief Print file infos.
void printInfos(juce::File file,
std::function<void(juce::String const&)> printer);
private:
enum TransportState
{
Stopped,
Starting,
Playing,
Stopping
};
void changeListenerCallback(juce::ChangeBroadcaster* source) override;
void changeState(TransportState new_state);
private:
size_t m_channels;
playingStoppedCallback m_playing_stopped_callback {nullptr};
bool is_looping {false};
juce::AudioFormatManager m_format_manager;
std::unique_ptr<juce::AudioFormatReaderSource> m_reader_source {nullptr};
juce::AudioTransportSource m_transport_source;
TransportState m_state {Stopped};
juce::AudioBuffer<float> m_buffer;
juce::AudioSourceChannelInfo m_audio_source_channel_info;
};
// ================================================================================ //
// SFPLAY~ //
// ================================================================================ //
class SfPlayTilde
: public engine::AudioObject
{
public: // methods
SfPlayTilde(model::Object const& model, Patcher& patcher);
~SfPlayTilde();
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
private:
bool openFile(juce::File file);
void openFileDialog();
void closeFileDialog();
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void prepare(dsp::Processor::PrepareInfo const& infos) override;
void release() override;
public: // internal
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
private:
juce::File m_file_to_read;
std::unique_ptr<juce::FileChooser> m_file_chooser;
SoundFilePlayer m_player;
};
}}
| 4,733
|
C++
|
.h
| 95
| 39.442105
| 93
| 0.560112
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,550
|
KiwiEngine_SfRecordTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_SfRecordTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
#include <juce_core/juce_core.h>
#include <juce_audio_formats/juce_audio_formats.h>
#include <juce_gui_basics/juce_gui_basics.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SOUNDFILE RECORDER //
// ================================================================================ //
class SoundFileRecorder
{
public: // methods
SoundFileRecorder();
~SoundFileRecorder();
bool start(const juce::File& file);
void stop();
bool isRecording() const;
bool write(dsp::Buffer const& input);
void setNumberOfChannels(size_t channels);
size_t getNumberOfChannels() const;
void prepare(double sample_rate, size_t vector_size);
private:
size_t m_channels;
std::vector<float const*> m_buffer_ref;
juce::TimeSliceThread m_background_thread;
std::unique_ptr<juce::AudioFormatWriter::ThreadedWriter> m_threaded_writer = nullptr;
double m_sample_rate = 0.;
size_t m_vector_size = 0;
std::mutex m_writer_lock;
juce::AudioFormatWriter::ThreadedWriter* m_active_writer {nullptr};
};
// ================================================================================ //
// SFRECORD~ //
// ================================================================================ //
class SfRecordTilde
: public AudioObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
SfRecordTilde(model::Object const& model, Patcher& patcher);
~SfRecordTilde();
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
private:
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void prepare(dsp::Processor::PrepareInfo const& infos) override;
void release() override;
bool openFile(juce::File file);
void openFileDialog();
void closeFileDialog();
void record(double duration_ms = -1);
void stop();
private:
const std::string m_extension = "wav";
juce::File m_file_to_write;
std::unique_ptr<juce::FileChooser> m_file_chooser;
SoundFileRecorder m_recorder;
double m_sample_rate = 0.;
long m_writer_count {0};
double m_time_to_stop_ms {-1};
};
}}
| 3,807
|
C++
|
.h
| 76
| 40.236842
| 93
| 0.533585
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,551
|
KiwiEngine_GateTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_GateTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiDsp/KiwiDsp_Signal.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// GATE~ //
// ================================================================================ //
class GateTilde : public AudioObject
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
GateTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void prepare(PrepareInfo const& infos) override final;
void performValue(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performSig(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
private:
void openOutput(int output);
private:
size_t m_opened_output;
size_t m_num_outputs;
};
}}
| 2,078
|
C++
|
.h
| 38
| 46.868421
| 93
| 0.535602
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,552
|
KiwiEngine_DivideTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_DivideTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// /~ //
// ================================================================================ //
class DivideTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
DivideTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,675
|
C++
|
.h
| 29
| 52.103448
| 97
| 0.505682
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,553
|
KiwiEngine_ClipTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_ClipTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <atomic>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// CLIP~ //
// ================================================================================ //
class ClipTilde : public AudioObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
ClipTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performMinMax(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performMin(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performMax(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
private: // methods
std::atomic<float> m_minimum;
std::atomic<float> m_maximum;
};
}}
| 2,218
|
C++
|
.h
| 38
| 50.552632
| 93
| 0.547225
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,554
|
KiwiEngine_MeterTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_MeterTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <atomic>
#include <chrono>
#include <KiwiTool/KiwiTool_Scheduler.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
/// ================================================================================ //
// METER~ //
// ================================================================================ //
class MeterTilde : public engine::AudioObject, tool::Scheduler<>::Timer
{
public: // usings
using clock_t = std::chrono::high_resolution_clock;
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
MeterTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void perform(dsp::Buffer const& intput, dsp::Buffer& output);
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
void release() override final;
void timerCallBack() override final;
private: // members
size_t m_interval;
dsp::sample_t m_current_peak;
size_t m_sample_index;
size_t m_target_sample_index;
std::atomic<float> m_last_peak;
std::atomic<bool> m_uptodate;
flip::Signal<float> & m_signal;
};
}
}
| 2,544
|
C++
|
.h
| 47
| 46.489362
| 93
| 0.517782
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,555
|
KiwiEngine_Metro.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Metro.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT METRO //
// ================================================================================ //
class Metro final : public engine::Object
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Metro(model::Object const& model, Patcher& patcher);
~Metro();
void receive(size_t index, std::vector<tool::Atom> const& args) override;
void timerCallBack();
private: // members
tool::Scheduler<>::duration_t m_period;
std::shared_ptr<tool::Scheduler<>::CallBack> m_task;
};
}}
| 1,870
|
C++
|
.h
| 34
| 47.794118
| 93
| 0.504614
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,556
|
KiwiEngine_Float.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Float.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// FLOAT //
// ================================================================================ //
class Float : public Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
Float(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
private:
double m_stored_value;
};
}}
| 1,669
|
C++
|
.h
| 31
| 47.548387
| 92
| 0.499038
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,557
|
KiwiEngine_Operator.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Operator.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT OPERATOR //
// ================================================================================ //
class Operator : public engine::Object
{
public:
Operator(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void bang();
virtual double compute(double lhs, double rhs) const = 0;
protected:
double m_lhs;
double m_rhs;
};
}}
| 1,746
|
C++
|
.h
| 32
| 45.53125
| 94
| 0.48132
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,558
|
KiwiEngine_PhasorTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_PhasorTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// PHASOR~ //
// ================================================================================ //
class PhasorTilde : public AudioObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
PhasorTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
void performSignal(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void performValue(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
private: // methods
void setFrequency(dsp::sample_t const& freq) noexcept;
void setPhase(dsp::sample_t const& phase) noexcept;
void setSampleRate(dsp::sample_t const& sample_rate);
dsp::sample_t getAndIncrementPhase(const dsp::sample_t inc);
private: // members
dsp::sample_t m_sr {0.f};
dsp::sample_t m_freq {0.f};
std::atomic<dsp::sample_t> m_phase {0.f};
std::atomic<dsp::sample_t> m_phase_inc {0.f};
};
}}
| 2,483
|
C++
|
.h
| 42
| 50.380952
| 93
| 0.543545
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,559
|
KiwiEngine_AdcTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_AdcTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_AudioInterface.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// ADC~ //
// ================================================================================ //
class AdcTilde : public AudioInterfaceObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
AdcTilde(model::Object const& model, Patcher& patcher);
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
};
}}
| 1,744
|
C++
|
.h
| 30
| 52.1
| 93
| 0.518856
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,560
|
KiwiEngine_FaustTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_FaustTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
class llvm_dsp_factory;
class llvm_dsp;
namespace kiwi { namespace engine {
// ================================================================================ //
// FAUST~ //
// ================================================================================ //
class FaustTilde : public engine::AudioObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
FaustTilde(model::Object const& model, Patcher& patcher);
~FaustTilde();
void receive(size_t index, std::vector<tool::Atom> const& args) override;
void prepare(dsp::Processor::PrepareInfo const& infos) override;
void attributeChanged(std::string const& name, tool::Parameter const& param) override;
private:
//! @brief Returns the faust libraries path
std::string getFaustLibsPath() const;
static int64_t getUserId(model::Object const& model);
//! @brief Get the compile options
std::vector<std::string> getCompileOptions() const;
//! @brief Set the DSP code
void setCompileOptions(std::vector<std::string>&& options);
//! @brief Get the DSP code
std::string const& getDspCode() const;
//! @brief Set the DSP code
void setDspCode(std::string&& code);
//! @brief Get the Edit code
std::string const& getEditCode() const;
//! @brief Set the Edit code
void setEditCode(std::string&& code);
//! @brief Get if the object has the lock for the codes
bool hasLock() const;
//! @brief Get if the object can grab the lock for the codes
bool canLock() const;
//! @brief Grab or leave the lock for the code
//! @return true if the action succeed, otherwise false
bool grabLock(bool state);
//! @brief Force to unlock the model
void forceUnlock();
//! @brief Open a file an notify that the DSP and Edit codes changed
void openFile(const std::string& file);
//! @brief Compile the current DSP code.
void compileDspCode();
//! @brief Get the time of a block size in ms.
double getBlockSizeInMS() { return static_cast<double>(m_block_size) / static_cast<double>(m_sample_rate); }
//! @brief Get the time of a block size in ms.
bool prepareDsp(size_t sampleRate, size_t blockSize) noexcept;
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
struct nop
{
template <typename T>
void operator() (T const &) const noexcept { }
};
class UIGlue;
class FileSelector;
class CodeEditor;
typedef std::unique_ptr<llvm_dsp_factory, bool(*)(llvm_dsp_factory*)> uptr_faust_factory;
typedef std::unique_ptr<llvm_dsp, nop> uptr_faust_instance;
uptr_faust_factory m_factory;
uptr_faust_instance m_instance;
std::mutex m_mutex;
std::vector<dsp::sample_t*> m_inputs;
std::vector<dsp::sample_t*> m_outputs;
std::string m_dsp_code;
std::string m_edit_code;
std::vector<std::string> m_compile_options {};
std::unique_ptr<UIGlue> m_ui_glue;
std::unique_ptr<FileSelector> m_file_selector;
std::unique_ptr<CodeEditor> m_code_editor;
int64_t m_lock_state = 0;
const int64_t m_user_id = 0;
size_t m_sample_rate = 44100;
size_t m_block_size = 64;
};
}}
| 4,993
|
C++
|
.h
| 93
| 43.55914
| 116
| 0.554066
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,561
|
KiwiEngine_Pow.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Pow.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_Operator.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT POW //
// ================================================================================ //
class Pow : public Operator
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
Pow(model::Object const& model, Patcher& patcher);
double compute(double lhs, double rhs) const override final;
};
}}
| 1,646
|
C++
|
.h
| 30
| 49.4
| 92
| 0.51254
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,562
|
KiwiEngine_MinusTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_MinusTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// -~ //
// ================================================================================ //
class MinusTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
MinusTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,673
|
C++
|
.h
| 29
| 52.034483
| 97
| 0.505057
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,563
|
KiwiEngine_LessEqualTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_LessEqualTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// <=~ //
// ================================================================================ //
class LessEqualTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
LessEqualTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,682
|
C++
|
.h
| 29
| 52.344828
| 97
| 0.507228
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,564
|
KiwiEngine_Send.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Send.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Beacon.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SEND //
// ================================================================================ //
class Send : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Send(model::Object const& model, Patcher& patcher);
Send() = default;
void receive(size_t index, std::vector<tool::Atom> const& args) override;
private:
tool::Beacon& m_beacon;
};
}}
| 1,749
|
C++
|
.h
| 33
| 46.363636
| 93
| 0.502773
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,565
|
KiwiEngine_Toggle.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Toggle.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT TOGGLE //
// ================================================================================ //
class Toggle : public engine::Object
{
private: // classes
class Task;
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Toggle(model::Object const& model, Patcher& patcher);
~Toggle();
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
private: // methods
void outputValue();
private: // members
flip::SignalConnection m_connection;
bool m_is_on;
};
}}
| 2,036
|
C++
|
.h
| 38
| 45.578947
| 100
| 0.515282
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,566
|
KiwiEngine_Number.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Number.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT NUMBER //
// ================================================================================ //
class Number : public engine::Object
{
public: // methods
Number(model::Object const& model, Patcher& patcher);
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
private: // methods
void outputValue();
private: // members
double m_value;
flip::SignalConnection m_connection;
};
}}
| 1,926
|
C++
|
.h
| 35
| 48.085714
| 100
| 0.520601
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,567
|
KiwiEngine_Pack.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Pack.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// PACK //
// ================================================================================ //
class Pack : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Pack(model::Object const& model, Patcher& patcher);
~Pack() = default;
void setElement(size_t index, tool::Atom const& atom);
void receive(size_t index, std::vector<tool::Atom> const& args) override;
private:
void output_list();
private:
std::vector<tool::Atom> m_list;
};
}}
| 1,851
|
C++
|
.h
| 35
| 45.228571
| 93
| 0.502948
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,568
|
KiwiEngine_LessTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_LessTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// <~ //
// ================================================================================ //
class LessTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
LessTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,671
|
C++
|
.h
| 29
| 51.965517
| 97
| 0.50443
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,569
|
KiwiEngine_Mtof.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Mtof.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// MTOF //
// ================================================================================ //
class Mtof : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Mtof(model::Object const& model, Patcher& patcher);
Mtof() = default;
void receive(size_t index, std::vector<tool::Atom> const& args) override;
};
}}
| 1,648
|
C++
|
.h
| 30
| 48.733333
| 93
| 0.493843
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,570
|
KiwiEngine_AudioInterface.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_AudioInterface.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_AudioControler.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// AUDIO_INTERFACE //
// ================================================================================ //
class AudioInterfaceObject : public AudioObject
{
public: // methods
AudioInterfaceObject(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const & args) override final;
std::vector<size_t> parseArgs(std::vector<tool::Atom> const& args) const;
virtual ~AudioInterfaceObject() = default;
protected: // members
engine::AudioControler& m_audio_controler;
std::vector<size_t> m_routes;
};
}}
| 1,863
|
C++
|
.h
| 33
| 50.090909
| 90
| 0.52921
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,571
|
KiwiEngine_Comment.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Comment.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT COMMENT //
// ================================================================================ //
class Comment : public engine::Object
{
public: // methods
Comment(model::Object const& model, Patcher& patcher);
~Comment();
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
};
}}
| 1,664
|
C++
|
.h
| 30
| 49.266667
| 92
| 0.503528
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,572
|
KiwiEngine_Loadmess.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Loadmess.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT LOADMESS //
// ================================================================================ //
class Loadmess : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Loadmess(model::Object const& model, Patcher& patcher);
~Loadmess() = default;
void receive(size_t index, std::vector<tool::Atom> const& args) override;
void loadbang() override;
private:
const std::vector<tool::Atom> m_args;
};
}}
| 1,781
|
C++
|
.h
| 33
| 46.818182
| 93
| 0.509113
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,573
|
KiwiEngine_DacTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_DacTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_AudioInterface.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// DAC~ //
// ================================================================================ //
class DacTilde : public AudioInterfaceObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
DacTilde(model::Object const& model, Patcher& patcher);
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
};
}}
| 1,744
|
C++
|
.h
| 30
| 52.1
| 93
| 0.518856
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,574
|
KiwiEngine_SnapshotTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_SnapshotTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SNAPSHOT~ //
// ================================================================================ //
class SnapshotTilde : public AudioObject
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
SnapshotTilde(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override final;
void perform(dsp::Buffer const& input, dsp::Buffer& output) noexcept;
void prepare(dsp::Processor::PrepareInfo const& infos) override final;
private: // members
std::atomic<dsp::sample_t> m_value {0.f};
};
}}
| 1,913
|
C++
|
.h
| 33
| 50.787879
| 93
| 0.526168
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,576
|
KiwiEngine_Delay.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Delay.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT DELAY //
// ================================================================================ //
class Delay final : public engine::Object
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& object, Patcher & patcher);
Delay(model::Object const& model, Patcher& patcher);
~Delay();
void receive(size_t index, std::vector<tool::Atom> const& args) override;
void bang();
private: // members
std::shared_ptr<tool::Scheduler<>::CallBack> m_task;
tool::Scheduler<>::clock_t::duration m_delay;
};
}}
| 1,861
|
C++
|
.h
| 34
| 47.529412
| 94
| 0.504928
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,577
|
KiwiEngine_EqualTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_EqualTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// ==~ //
// ================================================================================ //
class EqualTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
EqualTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,674
|
C++
|
.h
| 29
| 52.068966
| 97
| 0.504738
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,578
|
KiwiEngine_OSCReceive.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_OSCReceive.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
#include <juce_osc/juce_osc.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OSC.receive //
// ================================================================================ //
class OSCReceive
: public engine::Object
, private juce::OSCReceiver
, private juce::OSCReceiver::Listener<juce::OSCReceiver::RealtimeCallback>
{
public: // methods
OSCReceive(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override;
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
private: // methods
static tool::Atom OSCArgToAtom(juce::OSCArgument const& arg);
bool setPort(int new_port);
void oscMessageReceived(juce::OSCMessage const& msg) override;
void oscBundleReceived (juce::OSCBundle const& bundle) override;
};
}}
| 2,092
|
C++
|
.h
| 38
| 48.157895
| 92
| 0.548437
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,579
|
KiwiEngine_PlusTilde.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_PlusTilde.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_OperatorTilde.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// PLUS~ //
// ================================================================================ //
class PlusTilde : public OperatorTilde
{
public: // methods
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
PlusTilde(model::Object const& model, Patcher& patcher);
void compute(dsp::sample_t & result, dsp::sample_t const& lhs, dsp::sample_t const& rhs);
};
}}
| 1,671
|
C++
|
.h
| 29
| 51.965517
| 97
| 0.506962
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,580
|
KiwiEngine_Route.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Route.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// ROUTE //
// ================================================================================ //
class Route : public engine::Object
{
public: // methods
Route(model::Object const& model, Patcher& patcher);
void receive(size_t index, std::vector<tool::Atom> const& args) override;
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
private: // members
std::vector<tool::Atom> m_args {};
};
}}
| 1,710
|
C++
|
.h
| 31
| 48.709677
| 92
| 0.499687
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,581
|
KiwiEngine_Select.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Select.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <vector>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// SELECT //
// ================================================================================ //
class Select : public engine::Object
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher & patcher);
Select(model::Object const& model, Patcher& patcher);
~Select() = default;
void receive(size_t index, std::vector<tool::Atom> const& args) override;
private:
std::vector<tool::Atom> m_list;
};
}}
| 1,745
|
C++
|
.h
| 33
| 46.212121
| 93
| 0.501854
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,582
|
KiwiEngine_Equal.h
|
Musicoll_Kiwi/Modules/KiwiEngine/KiwiEngine_Objects/KiwiEngine_Equal.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Objects/KiwiEngine_Operator.h>
#include <KiwiEngine/KiwiEngine_Object.h>
namespace kiwi { namespace engine {
// ================================================================================ //
// OBJECT EQUAL //
// ================================================================================ //
class Equal : public Operator
{
public:
static void declare();
static std::unique_ptr<Object> create(model::Object const& model, Patcher& patcher);
Equal(model::Object const& model, Patcher& patcher);
double compute(double lhs, double rhs) const override final;
};
}}
| 1,653
|
C++
|
.h
| 30
| 49.633333
| 92
| 0.514085
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,583
|
KiwiDsp_Misc.h
|
Musicoll_Kiwi/Modules/KiwiDsp/KiwiDsp_Misc.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include "KiwiDsp_Def.h"
namespace kiwi
{
namespace dsp
{
// ================================================================================ //
// TOOLS //
// ================================================================================ //
//! @brief Gets if a size is a power of two.
//! @param size The size.
//! @return true if the size if a power of two, otherwise false.
static inline constexpr bool isPowerOfTwo(const size_t size) noexcept
{
// Decrement and Compare method : 9.
// http://www.exploringbinary.com/ten-ways-to-check-if-an-integer-is-a-power-of-two-in-c/
return size && ((size & (size - 1)) == 0);
}
// ==================================================================================== //
// ERROR //
// ==================================================================================== //
//! @brief The exception.
//! @details The class defines the std::exception objects that can be trown during of by
//! @details DSP objects during the compilation of a Chain object.
class Error : public std::runtime_error
{
public:
//! @brief The std::string constructor.
//! @param message The message of the error
explicit Error(const std::string& message) :
std::runtime_error(std::string("kiwi::dsp: ") + message) {}
//! @brief The const char* constructor.
//! @param message The message of the error
explicit Error(const char* message) :
std::runtime_error(std::string("kiwi::dsp: ") + std::string(message)) {}
//! @brief The destructor.
virtual inline ~Error() noexcept = default;
};
// ==================================================================================== //
// TIMER //
// ==================================================================================== //
//! @brief The timer.
//! @details The class uses high resolution clocks to estimate the time that the CPU uses
//! @details for a set of processes.
class Timer
{
public: // methods
//! @brief The nanosecond precision.
typedef std::chrono::nanoseconds nanoseconds;
//! @brief The microseconds precision.
typedef std::chrono::microseconds microseconds;
//! @brief The milliseconds precision.
typedef std::chrono::milliseconds milliseconds;
//! @brief The seconds precision.
typedef std::chrono::seconds seconds;
//! @brief The minutes precision.
typedef std::chrono::minutes minutes;
//! @brief The hours precision.
typedef std::chrono::hours hours;
//! @brief The constructor.
Timer() = default;
//! @brief The destrcutor.
~Timer() {}
//! @brief Gets the ellapsed time.
template <typename TDur>
double get(const bool reset) noexcept
{
static_assert(std::chrono::__is_duration<TDur>::value,
"Kiwi::Dsp::Timer : The template must be a duration.");
const std::chrono::high_resolution_clock::time_point next = std::chrono::high_resolution_clock::now();
const double time = std::chrono::duration_cast<TDur>(next - m_start).count();
if(reset)
{
m_start = next;
}
return time;
}
//! @brief Starts the timer.
inline void start() noexcept
{
m_start = std::chrono::high_resolution_clock::now();
}
private: // members
std::chrono::high_resolution_clock::time_point m_start;
};
}
}
| 5,254
|
C++
|
.h
| 101
| 40.128713
| 118
| 0.459307
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,584
|
KiwiDsp_Def.h
|
Musicoll_Kiwi/Modules/KiwiDsp/KiwiDsp_Def.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <iostream>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <chrono>
#include <exception>
#include <vector>
#include <set>
#include <memory>
#include <atomic>
#include <mutex>
#ifndef __APPLE__
#include "malloc.h"
#endif
namespace kiwi
{
namespace dsp
{
#ifdef KIWI_DSP_FLOAT
typedef float sample_t;
#else
typedef double sample_t;
#endif
const sample_t pi = 3.14159265358979323846264338327950288;
}
}
| 1,412
|
C++
|
.h
| 43
| 29.55814
| 90
| 0.610863
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,585
|
KiwiDsp_Chain.h
|
Musicoll_Kiwi/Modules/KiwiDsp/KiwiDsp_Chain.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <map>
#include <queue>
#include "KiwiDsp_Processor.h"
#include "KiwiDsp_Misc.h"
namespace kiwi
{
namespace dsp
{
// ==================================================================================== //
// CHAIN //
// ==================================================================================== //
//! @brief An audio rendering class that manages processors in a graph structure.
//! @details Updating the chain can be updated by incrementingly adding processors and connecting them.
//! The chain can then be prepared with a certain samplerate and vectorsize making it's tick
//! function ready to be called in a separate thread.
//! The chain is transactional that's to say that changes will not be effective
//! until either prepare or update is called.
class Chain final
{
public: // methods
//! @brief The default constructor.
//! @details Allocates and initializes an empty Chain object.
//! All the initializations will be performed with the compile method of the Chain object.
//! @see prepare
Chain();
//! @brief The destructor.
//! @details Deallocate memory initialized during prepare and will call every processors release method
//! as their computation. Note that as processors ownership are shared, chain destructor might not call
//! processor destructor. As releasing might throw it's better practice to call release
//! before calling the chain destructor and catch exception if needed.
~Chain();
//! @brief Updates the chain making changes effective.
//! @details As the chain is transactional changes are not effective immediatly. Changes are stored in
//! a command stack that update will unstack and execute. Updating the chain will keep in it's previous
//! state that it's to say that is the chain was prepared it will keep it that way. Update can be called
//! concurrently with tick.
void update();
//! @brief Allocates memory needed for chain execution.
//! @details The prepare method will allocate that signal that will passed through the graph.
//! All processors prepare method will be called. If the prepare method is called twice, the second
//! call will first release and reallocate the entire graph. If changes have been made to the chain
//! prepare will make them effective as update would do. Ticking the chain without preparing
//! is legal but does nothing. Prepare can be called concurretly with tick.
void prepare(size_t const samplerate, size_t const vectorsize);
//! @brief Deallocate memory needed to perform tick method.
//! @details Will call release on every processor and will deallocate signal memory.
//! As release might throw it shal be called before chain destructor. Calling release
//! will disable chain tick.
//! @exception Error
void release();
//! @brief Gets the current sample rate.
//! @see getVectorSize
size_t getSampleRate() const noexcept;
//! @brief Gets the current vector size.
//! @see getSampleRate
size_t getVectorSize() const noexcept;
//! @brief Adds a processor to the chain.
//! @details Ownership is shared between caller and chain. The caller might
//! keep a reference to the processor and update it. Calling addProcessor will add a command
//! to the stack that will be executed at update or prepare time. Adding the same processor
//! twice will cause an exception to be thrown at update time.
void addProcessor(std::shared_ptr<Processor> processor);
//! @brief Removes processors from the chain.
//! @details Removes processor from the chain. The shared pointer then decrements its count.
//! The change will be effective as soon as update or prepare is called. Removing a non existing
//! processor will throw at update time.
void removeProcessor(Processor& proc);
//! @brief Connects two processors.
//! @details Connects the source node (upper node) to dest node (lower node) making
//! signal transimission effective. Connecting an non existing node will result in
//! exception being called at update time. Connecting might also detect loop and throw.
void connect(Processor& source, size_t outlet_index,
Processor& dest, size_t inlet_index);
//! @brief Disconnect two processors.
//! @details Disconnect the source node (upper node) from dest node (lower node) disabling
//! signal transimission.
void disconnect(Processor& source, size_t outlet_index,
Processor& destination, size_t inlet_index);
//! @brief Ticks once all the Processor objects. Not recursive.
//! @details Call iteratively all the node on their perform method.
//! if the chain is not prepared the tick will result in doing nothing.
//! Prepare, release, updates can be made concurrently to tick.
void tick() noexcept;
private: // classes
//! @brief Chain state regarding preparation.
//! @details If chain is not prepared tick will do nothing.
enum class State : uint8_t
{
NotPrepared = 0, ///< The Chain has not been prepared.
Preparing = 1, ///< The Chain is being prepared.
Prepared = 2 ///< The chain has been prepared.
};
class Node;
private: // methods
//! @brief Functor called by indexNodes to index a node.
//! @details To avoid too many recursion on the graph, index_node will also
//! detect loops.
struct index_node;
//! @brief Funtor that checks if the node countains the processor
//! @detail Used to retrieve the node that have a certain processor in findNode;
struct compare_proc;
//! @brief Returns an iterator to the object having processor proc.
std::vector<std::unique_ptr<Node>>::iterator findNode(Processor& proc);
//! @brief Returns an const iterator to the object having node_id.
std::vector<std::unique_ptr<Node>>::const_iterator findNode(Processor& proc) const;
//! @brief Attributes an index to the node before sorting by index.
//! @details Indexing guarantees that every node will have a greater index than
//! than all its parent node. Called during prepare.
void indexNodes();
//! @brief Sorts all node by index before computing.
//! @details Sorting node will guarantee that all parent node will be executed
//! before a chil node execution.
void sortNodes();
private: // commands
//! @brief The command that will making adding a processor effective.
void execAddProcessor(std::shared_ptr<Processor> proc);
//! @brief The command that will making removing a processor effective.
void execRemoveProcessor(Processor* proc);
//! @brief The command that will making connection effective.
void execConnect(Processor* source, size_t outlet_index,
Processor* dest, size_t inlet_index);
//! @brief The command that will making disconnection effective.
void execDisconnect(Processor* source, size_t outlet_index,
Processor* dest, size_t inlet_index);
//! @brief Puts back a node in to the commands' list in order to add it again.
//! @details If a nodes processor doesn't require compuration, for optimization concern,
//! we remove it from the chain but it back into the command list. If the node status changes afterward
//! the chain may be able to reinsert it into the chain.
void restackNode(Node & node);
//! @brief Returns a allocated signal for disconnected inlets
//! @details Since disconnected inlet never modify their signal they can share the same signal.
//! @details The first disconnected inlet to ask this will cause it's allocation.
std::shared_ptr<Signal> getSignalIn();
//! @brief Returns a allocated signal for disconnected outlets.
//! @details Since disconnected outlets signals are never used after they're computed and never read,
//! @details we can optimize and feed them the same signal.
std::shared_ptr<Signal> getSignalOutlet(size_t outlet_index);
//! @brief Returns an allocated signal for fanning inlets.
//! @details Since fanning inlets always copy their parent node signal before computing.
//! @details we can optimize and feed them the same buffer which will be overwritten before node computation.
std::shared_ptr<Signal> getSignalInlet(size_t inlet_index);
private: // members
std::vector<std::unique_ptr<Node>> m_nodes;
size_t m_sample_rate;
size_t m_vector_size;
State m_state;
std::deque<std::function<void(void)>> m_commands;
std::mutex m_tick_mutex;
std::weak_ptr<Signal> m_signal_in;
std::map<size_t, std::weak_ptr<Signal>> m_signal_outlet;
std::map<size_t, std::weak_ptr<Signal>> m_signal_inlet;
};
// ================================================================================ //
// NODE //
// ================================================================================ //
//! @brief The Node object wraps and manages a Processor object inside a Chain object.
//! @details The node can be connected to other node and enables signal data
//! to go through its pins (inlet, outlet). Node also manages its signal allocation via
//! its prepare and release method.
class Chain::Node final
{
public: // typedefs
using uPtr = std::unique_ptr<Node>;
public: // methods
//! @brief Constructor.
Node(std::shared_ptr<Processor> processor);
// @brief Destructor.
~Node();
//! @brief Connects the node input pin to another node output pin.
//! @details Returns true didn't exist yet and was effectively inserted.
bool connectInput(const size_t input_index, Node& other_node, const size_t output_index);
//! @brief Disconnect the node input pin from another node output pin.
//! @details Returns true existed and was effectively removed.
bool disconnectInput(const size_t input_index, Node& other_node, const size_t output_index);
//! @brief Prepare the Node object.
//! @details Allocates and bind its memory before its computation. Call its processor prepare method.
bool prepare(Chain& chain);
//! @brief The digital signal processing perform method.
//! @details Feeds the processor a buffer of sample to be processed.
void perform() noexcept;
//! @brief Releases the node disabling performing it.
void release();
private: // nested classes
class Pin;
class Tie;
private: // members
std::shared_ptr<Processor> m_processor;
std::vector<Pin> m_inlets;
std::vector<Pin> m_outlets;
Buffer m_inputs;
Buffer m_outputs;
std::vector<Buffer> m_buffer_copy;
size_t m_index;
private: // deleted methods
Node(Node const& other) = delete;
Node(Node && other) = delete;
Node& operator=(Node const& other) = delete;
Node& operator=(Node && other) = delete;
friend class Chain;
};
// ================================================================================ //
// NODE::PIN //
// ================================================================================ //
//! @brief The pin helds a set of tie that points to other pins.
class Chain::Node::Pin
{
public: // methods
//! @brief Constructor.
//! @param owner The Node that holds this Pin.
//! @param index The index of the Pin.
Pin(Node& owner, const size_t index);
//! @brief move constructor.
//! @details Destructing pin will cause its deconnection.
Pin(Pin && other);
//! @brief Destructor.
virtual ~Pin();
//! @brief Connects the inlet to a node outlet.
//! @return Returns true if the connection didn't exist and was inserted.
bool connect(Pin& other_pin);
//! @brief Disconnects the nodes.
//! @return Returns true if the connection existed and was removed..
bool disconnect(Pin& other_pin);
//! @brief Removes all connection from the pin.
void disconnect();
public: // members
Node& m_owner;
const size_t m_index;
Signal::sPtr m_signal;
std::set<Node::Tie> m_ties;
private: // deleted methods
Pin(Pin const& other) = delete;
Pin& operator=(Pin const& other) = delete;
friend class Node;
};
// ==================================================================================== //
// NODE::CONNECTION //
// ==================================================================================== //
//! @brief A tie is a reference held by a pin to another pin.
class Chain::Node::Tie final
{
public: // methods
//! @brief Constructor with the pin that will be referenced.
Tie(Pin& pin);
//! @brief Copy constructor of Tie.
Tie(Tie const& other) = default;
//! @brief Comparison operator. Compares pin and pins' indexes.
bool operator<(Tie const& other) const noexcept;
~Tie() = default;
public: // members
Pin & m_pin;
private: // deleted methods
Tie() = delete;
};
// ==================================================================================== //
// LOOPERROR //
// ==================================================================================== //
//! @brief An exception to detect loops.
//! @details An exception that is thrown whenever a loop is detected in a chain.
//! @todo Add more infos about the detected loop.
class LoopError : public Error
{
public:
//! @brief The std::string constructor.
//! @param message The message of the error
explicit LoopError(const std::string& message) :
Error("looperror: " + message)
{}
//! @brief The const char* constructor.
//! @param message The message of the error
explicit LoopError(const char* message) :
Error(std::string("looperror: ") + std::string(message)) {}
//! @brief The destructor.
~LoopError() noexcept override = default;
};
}
}
| 18,707
|
C++
|
.h
| 291
| 49.309278
| 121
| 0.539779
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,586
|
KiwiDsp_Signal.h
|
Musicoll_Kiwi/Modules/KiwiDsp/KiwiDsp_Signal.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <memory>
#include "KiwiDsp_Def.h"
namespace kiwi
{
namespace dsp
{
// ==================================================================================== //
// SIGNAL //
// ==================================================================================== //
//! @brief A class that wraps a vector of sample_t.
//! @details The class is a wrapper for a vector of sample_t values that offers optimized
//! operations. The class also offers static methods to perform these operations
//! with other Signal objects.
class Signal
{
public: // methods
typedef std::shared_ptr<Signal> sPtr;
typedef std::shared_ptr<const Signal> scPtr;
typedef std::unique_ptr<Signal> uPtr;
//! @brief Constructs and fill a Signal object.
//! @details Allocates a Signal object of a specific size and initializes it with a default value.
//! @param size The number of samples.
//! @param val The default value of the signal.
Signal(const size_t size, const sample_t val = sample_t(0.));
//! @brief Move constructor.
//! @details Moves the content of a Signal object to a new one.
//! The size of the other signal is set to 0 and its data are reset to nullptr.
//! @param other The other Signal object.
Signal(Signal&& other) noexcept;
//! @brief Move assignment operator
//! @details Moves the content of a Signal to this signal.
//! The size of the other signal is set to 0 and its data are reset to nullptr.
//! @param other The other Signal object.
Signal& operator=(Signal&& other) noexcept;
//! @brief The destructor.
//! @details Frees the content of the Signal object if needed.
~Signal();
//! @brief Gets the number of samples that the Signal object currently holds.
size_t size() const noexcept;
//! @brief Returns a read pointer to the samples data.
sample_t const* data() const noexcept;
//! @brief Returns a write pointer to the samples data.
sample_t* data() noexcept;
//! @brief Gets a read sample_t for a given index.
//! @param index of the sample requested. Must be lower than signal size.
sample_t const& operator[](const size_t index) const;
//! @brief Gets a write sample_t for a given index.
//! @param index of the sample requested. Must be lower than signal size.
sample_t& operator[](const size_t index);
//! @brief Fill this Signal with a new value.
//! @param value The value for every signal sample.
void fill(sample_t const& value) noexcept;
//! @brief Copies the samples of another signal into it.
void copy(Signal const& other_signal) noexcept;
//! @brief Adds a Signal to this one.
void add(Signal const& other_signal) noexcept;
//! @brief Adds two Signal together and returns the resulting Signal.
static void add(Signal const& signal_1, Signal const& signal_2, Signal& result);
private: // members
size_t m_size;
sample_t* m_samples;
private: // deleted methods
Signal() = delete;
Signal(Signal const& other) = delete;
Signal& operator=(Signal& other) = delete;
};
// ==================================================================================== //
// BUFFER //
// ==================================================================================== //
//! @brief A class that wraps a vector of Signal objects.
//! @details The class is a wrapper for a vector of Signal objects that offers optimized
//! operations. It can either own its own memory or share it with the outside.
class Buffer
{
public: // methods
//! @brief Default constructor. Creates an empty buffer.
//! @details SetChannels can the be used to feed signals
Buffer();
//! @brief A constructor that aggregates signals
//! @details Beware that the buffer now share the ownership with caller.
//! Clean has to be called afterwards to release memory.
//! signals must have the same size to be inserted in the Buffer.
//! @param signals A vector of signals. Shall have same vectorsize.
Buffer(std::vector<Signal::sPtr> signals);
//! @brief The filled constructor.
//! @details Allocates a Buffer object with a specific number of channels and number
//! of samples per channels. The matrix of sample_t can also be initialized
//! with a default value.
//! @param nchannels The number of channels of the buffer.
//! @param nsamples The number of samples per channels.
//! @param val The default value of the signal.
Buffer(const size_t nchannels, const size_t nsamples, const sample_t val = 0.);
//! @brief The move constructor.
//! @details Moves the content of a Buffer object to a new one.
//! The other Buffer will be reset to an empty state.
//! @param other The Buffer object you want to move.
Buffer(Buffer&& other) noexcept;
//! @brief The move assignment operator.
//! @details Moves the content of a Buffer object to a new one.
//! The other Buffer will be reset to an empty state.
//! @param other The Buffer object you want to move.
Buffer& operator=(Buffer&& other) noexcept;
//! @brief The destructor.
//! @details Frees the content of the Buffer object if needed.
~Buffer();
//! @brief Resets the entire buffer with new signals fed to him.
//! @details If the buffer was not empty it will be cleared.
//! Channels will then share ownership with caller.
//! Clean has to be called to release them.
//! signals must have the same size to be inserted in the Buffer.
//! @param signals A vector of aggregated signals. Shall have same vectorsize.
void setChannels(std::vector<Signal::sPtr> signals);
//! @brief Clears buffers data. The resulting buffer will be empty.
//! @brief If signal ownership was shared this method will release signal.
void clear();
//! @brief Gets the vector size of the Buffer object.
size_t getVectorSize() const noexcept;
//! @brief Gets the number of channels of the Buffer object.
size_t getNumberOfChannels() const noexcept;
//! @brief Returns true if the Buffer object has no Signal.
bool empty() const noexcept;
//! @brief Gets the Signal object for a given channel.
Signal const& operator[](const size_t index) const;
//! @brief Gets the Signal object for a given channel.
Signal& operator[](const size_t index);
private: // members
size_t m_vectorsize;
std::vector<Signal::sPtr> m_signals;
private: // deleted methods
Buffer(Buffer const& other) = delete;
Buffer& operator=(Buffer const& other) = delete;
};
}
}
| 9,152
|
C++
|
.h
| 149
| 47.442953
| 110
| 0.55579
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,587
|
KiwiDsp_Processor.h
|
Musicoll_Kiwi/Modules/KiwiDsp/KiwiDsp_Processor.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include "KiwiDsp_Signal.h"
namespace kiwi
{
namespace dsp
{
class Chain;
// ==================================================================================== //
// PERFORM CALL BACKC //
// ==================================================================================== //
//! @brief Pure virtual interface that defines a perform function to be implemented by child classes.
//! @details The call back is held by the processor and enables calling perform.
//! Using the IPerformCallBack interface enanles dynamical perform method in an efficient way.
//! The implementation of the interface depends on the child processor type.
class IPerformCallBack
{
public:
//! @brief The default contrustor.
IPerformCallBack() = default;
//! @brief Destructor
virtual ~IPerformCallBack() = default;
//! @brief pure virtual method that perform input and output buffers.
virtual void perform(Buffer const& intput, Buffer& output) = 0;
};
//! @brief Templated implementation of IPerformCallBack. Templated on type of processor.
//! @details The PerformCallBack acts as std::function but encapsulate a pointer of method to avoid
//! overhead generated by an std::function indirection.
template<class TProc>
class PerformCallBack : public IPerformCallBack
{
public:
//! @brief Constructor, get a pointer to the processor and its call back to be called later.
PerformCallBack(TProc & processor, void (TProc::*call_back)(Buffer const& input, Buffer &output)):
m_processor(processor),
m_call_back(call_back)
{
}
//! @brief Implementation of perform that binds a processor and its method.
void perform(Buffer const& input, Buffer& output) override final
{
(m_processor.*m_call_back)(input, output);
}
//! @brief Destructor.
//! @detilas The callback doesn't hold ownership of either the processor or the processor's method
//! therefor the no destruction occurs in destructor.
~PerformCallBack() = default;
private:
TProc& m_processor;
void (TProc::*m_call_back)(Buffer const& input, Buffer &output);
};
// ==================================================================================== //
// PROCESSOR //
// ==================================================================================== //
//! @brief The pure virtual class that processes digital signal in a Chain object.
//! @details The class is pure virtual and allows to implement digital signal processing.
//! You should implement the virtual methods prepare, perform and release.
//! @see Buffer and Infos
class Processor
{
public: // classes
struct PrepareInfo
{
const size_t sample_rate;
const size_t vector_size;
const std::vector<bool> &inputs;
};
public: // methods
//! @brief The constructor.
//! @details Allocates and initializes a default Processor object.
//! @param ninputs The number of inputs.
//! @param noutputs The number of outputs.
Processor(const size_t ninputs, const size_t noutputs) noexcept :
m_ninputs(ninputs), m_noutputs(noutputs) {}
//! @brief The destructor.
virtual ~Processor() = default;
//! @brief Gets the current number of inputs.
//! @return The number of inputs of the Processor object.
//! @see getNumberOfOutputs()
inline size_t getNumberOfInputs() const noexcept {return m_ninputs;}
//! @brief Gets the current number of outputs.
//! @return The number of outputs of the Processor object.
//! @see getNumberOfInputs()
inline size_t getNumberOfOutputs() const noexcept {return m_noutputs;}
//! @brief Returns true if the processor shall be performed by the chain.
//! @details Checks it the perform callback is well set by the processor.
bool shouldPerform() const noexcept
{
return m_call_back != nullptr;
}
protected: // methods
//! @brief Constructs a callback that will bind a processor and its perform method.
//! @details setPerformCallBack shall be called by the prepare method to set the callback
//! that will be called when chain processes a processor.
//! Different methods can be set as callback depending on PrepareInfo status.
template<class TProc>
void setPerformCallBack(TProc* processor,
void (TProc::*call_back)(Buffer const& input, Buffer &output))
{
m_call_back.reset(new PerformCallBack<TProc>(*processor, call_back));
}
private: // methods
//! @brief Prepares everything for the perform method.
//! @details You should use this method to check the vector size, the sample rate,
//! the connected inputs and outputs and to allocate memory if needed.
//! Preparing should also set the callback to be called by the chain.
//! Not setting the callback will result in the processor not being called by the chain.
//! @param infos The DSP informations.
//! @see perform() and release()
virtual void prepare(PrepareInfo const& infos) = 0;
//! @brief Performs the digital signal processing.
//! @details Triggers the callback set during prepare phase.
//! @param input The input Buffer object.
//! @param output The output Buffer object.
//! @see prepare() and release()
inline void perform(Buffer const& input, Buffer& output) noexcept
{
m_call_back->perform(input, output);
}
//! @brief Releases everything after the digital signal processing.
//! @details You can use this method to free the memory allocated during the call of
//! the prepare method for example.
//! @see prepare() and perform()
virtual void release() {}
private: // members
const size_t m_ninputs;
const size_t m_noutputs;
std::unique_ptr<IPerformCallBack> m_call_back;
friend class Chain;
};
}
}
| 8,239
|
C++
|
.h
| 145
| 43.448276
| 110
| 0.552212
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,588
|
KiwiServer_Server.h
|
Musicoll_Kiwi/Modules/KiwiServer/KiwiServer_Server.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <flip/detail/PortFactoryListener.h>
#include <flip/detail/PortListener.h>
#include <flip/contrib/transport_tcp/PortTransportServerTcp.h>
#include <flip/DocumentServer.h>
#include <KiwiModel/KiwiModel_PatcherUser.h>
#include <KiwiModel/KiwiModel_PatcherValidator.h>
#include <juce_core/juce_core.h>
#include <atomic>
#include <set>
namespace kiwi
{
namespace server
{
// ================================================================================ //
// SERVER //
// ================================================================================ //
//! @brief Converts an int64_t into a string representing it.
std::string hexadecimal_convert(uint64_t hexa_decimal);
//! @brief The Server class.
class Server : public flip::PortFactoryListener, public flip::PortListener
{
public: // classes
class Session;
class Logger
{
public: // methods
//! @brief Constructor
Logger(juce::File const& file, juce::String const& welcome_message);
//! @brief Destructor.
~Logger();
//! @brief Logs a message
void log(juce::String const& message);
private: // members
uint64_t m_limit;
juce::FileLogger m_jlogger;
};
public: // methods
//! @brief Constructor.
//! @details Initializes socket and creates backend directory if not there.
Server(uint16_t port,
juce::File backend_directory,
std::string const& open_token,
std::string const& kiwi_version);
//! @brief Destructor.
//! @details Disconnect all users and clean sessions. onDisconnected will be called for all port.
~Server();
//! @brief Process the socket hence process all sessions.
void process();
//! @brief Returns a list of sessions currenty opened.
std::set<uint64_t> getSessions() const;
//! @brief Returns a list of users connected to session
std::set<uint64_t> getConnectedUsers(uint64_t session_id) const;
private: // methods
//! @brief Called when a user connects to a document.
void onConnected(flip::PortBase & port);
//! @brief Called when a user has been disconnected from a document.
void onDisconnected(flip::PortBase & port);
//! @brief Get the path for a given session.
juce::File getSessionFile(uint64_t session_id) const;
//! @brief Creates and empy document.
//! @details Used by node to retrieve empty if document not yet opened.
//! Returns true if the empty document exists.
bool createEmptyDocument();
private: // methods
// PortFactoryListener
void port_factory_add(flip::PortBase & port) override final;
void port_factory_remove(flip::PortBase & port) override final;
// PortListener
void port_greet(flip::PortBase& port) override final;
void port_commit(flip::PortBase& port, flip::Transaction const & tx) override final;
void port_squash(flip::PortBase& port,
flip::TxIdRange const& range,
flip::Transaction const& tx) override final;
void port_push(flip::PortBase& port, flip::Transaction const& tx) override final;
void port_signal(flip::PortBase& port, const flip::SignalData & data) override final;
private: // variables
juce::File m_backend_directory;
std::string m_open_token;
std::string m_kiwi_version;
std::map <uint64_t, Session> m_sessions;
flip::PortTransportServerTcp m_socket;
std::set <flip::PortBase *> m_ports;
Logger m_logger;
static const char* kiwi_file_extension;
private: // deleted methods
Server() = delete;
Server(Server const& other) = delete;
Server(Server &&other) = delete;
Server &operator=(Server const& other) = delete;
Server &operator=(Server &&other) = delete;
};
// ================================================================================ //
// SERVER SESSION //
// ================================================================================ //
class Server::Session final
{
public: // methods
//! @brief Constructor.
//! @details Create a Session by moving another Session.
Session(Session && rhs);
//! @brief Constructor
//! @details Constructor will load the document if file exists. backend_file is
//! the file in which the session will save and load document.
Session(uint64_t identifier,
juce::File const& backend_file,
std::string const& token,
std::string const& kiwi_version,
Server::Logger & logger);
//! @brief Destructor.
//! @details Unbinds all documents and ports.
~Session();
//! @brief Returns the id of the session.
uint64_t getId() const;
//! @brief Saves the document into designated backend file.
//! @details Returns true if saving succeeded.
bool save() const;
//! @brief Loads the document from designated backend file.
bool load();
//! @brief Binds user to session.
void bind(flip::PortBase & port);
//! @brief Unbinds user from session.
//! @details If user that disconnect is the last one, the session will be saved.
void unbind(flip::PortBase & port);
//! @brief Returns a list of connected users.
std::set<uint64_t> getConnectedUsers() const;
private: // methods
//! @brief Checks if user has access to this particuliar session.
bool authenticateUser(uint64_t user_id, std::string metadata) const;
//! @brief Replies to a client with a list of connected users.
void sendConnectedUsers() const;
private: // members
const uint64_t m_identifier;
const std::string m_hex_id;
std::unique_ptr<model::PatcherValidator> m_validator;
std::unique_ptr<flip::DocumentServer> m_document;
std::vector<flip::SignalConnection> m_signal_connections;
juce::File m_backend_file;
std::string m_token;
std::string m_kiwi_version;
Logger & m_logger;
private: // deleted methods
Session() = delete;
Session(const Session & rhs) = delete;
Session& operator = (const Session & rhs) = delete;
Session& operator = (Session && rhs) = delete;
};
}
}
| 9,117
|
C++
|
.h
| 163
| 40.662577
| 109
| 0.520924
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,589
|
KiwiApp.h
|
Musicoll_Kiwi/Client/Source/KiwiApp.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include "KiwiApp_Application/KiwiApp_Instance.h"
#include "KiwiApp_General/KiwiApp_StoredSettings.h"
#include "KiwiApp_General/KiwiApp_LookAndFeel.h"
#include "KiwiApp_Components/KiwiApp_TooltipWindow.h"
#include "KiwiApp_Network/KiwiApp_ApiController.h"
namespace ProjectInfo
{
const char* const projectName = "Kiwi";
const char* const versionString = "v1.1";
const int versionNumber = 0x110;
}
namespace kiwi
{
// ================================================================================ //
// KiWi APPLICATION //
// ================================================================================ //
class KiwiApp
: public juce::JUCEApplication
, public NetworkSettings::Listener
, public juce::MultiTimer
{
public: // methods
// ================================================================================ //
// JUCEApplication //
// ================================================================================ //
//! @brief Called when the application starts.
void initialise(juce::String const& commandLine) override;
//! @brief Indicates that the user has tried to start up another instance of the app.
void anotherInstanceStarted(juce::String const& command_line) override;
//! @brief Called to allow the application to clear up before exiting.
void shutdown() override;
//! @brief Called when the operating system is trying to close the application.
void systemRequestedQuit() override;
//! @brief Returns the application's name.
const juce::String getApplicationName() override;
//! @brief Returns the application's version number.
const juce::String getApplicationVersion() override;
//! @brief Checks whether multiple instances of the app are allowed.
bool moreThanOneInstanceAllowed() override;
//! @brief Timer call back, processes the scheduler events list.
void timerCallback(int timer_id) override;
//! @brief Returns true if the app is running in a Mac OSX operating system.
static bool isMacOSX();
//! @brief Returns true if the app is running in a Linux operating system.
static bool isLinux();
//! @brief Returns true if the app is running in a Windows operating system.
static bool isWindows();
//==============================================================================
//! @brief Get the current running application instance.
static KiwiApp& use();
//! @brief Get the current running application instance.
static KiwiApp* getApp();
//! @brief Get the current running kiwi instance.
static Instance& useInstance();
//! @brief Get the Api object.
static Api& useApi();
//! @brief Gets the application scheduler.
static tool::Scheduler<>& useScheduler();
//! @brief Returns the Kiwi resources directory.
juce::File getKiwiResourcesDirectory();
//! @brief Returns the Kiwi object Help directory.
juce::File getKiwiObjectHelpDirectory();
//! @brief Returns the Kiwi examples directory.
juce::File getKiwiExamplesDirectory();
//! @brief Try to find a help file given an object class name.
juce::File findHelpFile(std::string const& classname) const;
//! @brief Sets the auth user.
static void setAuthUser(Api::AuthUser const& auth_user);
//! @brief Returns the current user
static Api::AuthUser const& getCurrentUser();
//! @brief enum describing global file locations for the app.
enum FileLocations
{
Home,
Open,
Save,
Download,
Upload,
};
//! @brief Returns the directory corresponding to a specific location.
static juce::File getGlobalDirectoryFor(FileLocations location);
//! @brief Sets the directory corresponding to a specific location.
static void setGlobalDirectoryFor(FileLocations location, juce::File path);
//! @brief Log-out the user
static void logout();
//! @brief Return true if the application can connect to the server.
static bool canConnectToServer();
//! @brief Get the current running engine instance.
static engine::Instance& useEngineInstance();
//! @brief Get the user id associated to this running application instance.
static uint64_t userID();
//! @brief Returns the application stored settings.
static StoredSettings& useSettings();
//! @brief Returns the MenuBarModel.
static juce::MenuBarModel* getMenuBarModel();
//! @brief Returns the application look and feel.
static LookAndFeel& useLookAndFeel();
//! @brief Returns the Tooltip Window component.
static TooltipWindow& useTooltipWindow();
// ================================================================================ //
// CONSOLE //
// ================================================================================ //
//! @brief post a log message in the Console.
static void log(std::string const& text);
//! @brief post a message in the Console.
static void post(std::string const& text);
//! @brief post a warning message in the Console.
static void warning(std::string const& text);
//! @brief post an error message in the Console.
static void error(std::string const& text);
//==============================================================================
//! @brief Attempt to close the given window asking user to save file if needed.
void closeWindow(Window& window);
// ================================================================================ //
// APPLICATION MENU //
// ================================================================================ //
//! @brief The Kiwi Application menu model class
struct MainMenuModel : public juce::MenuBarModel
{
MainMenuModel();
juce::StringArray getMenuBarNames();
juce::PopupMenu getMenuForIndex(int topLevelMenuIndex, const juce::String& menuName);
void menuItemSelected(int menuItemID, int topLevelMenuIndex);
};
//! @brief Called by MainMenuModel to get the menu names
juce::StringArray getMenuNames();
//! @brief Called by MainMenuModel to create menus
void createMenu (juce::PopupMenu& menu, const juce::String& menuName);
//! @brief Called by createMenu to create each menu
void createOpenRecentPatchersMenu(juce::PopupMenu& menu);
void createAccountMenu(juce::PopupMenu& menu);
void createFileMenu(juce::PopupMenu& menu);
void createEditMenu(juce::PopupMenu& menu);
void createViewMenu(juce::PopupMenu& menu);
void createOptionsMenu(juce::PopupMenu& menu);
void createWindowMenu(juce::PopupMenu& menu);
void createHelpMenu(juce::PopupMenu& menu);
//! @brief Called by MainMenuModel to handle the main menu command
void handleMainMenuCommand(int menuItemID);
// ================================================================================ //
// APPLICATION COMMAND //
// ================================================================================ //
//! @brief Bind a command target to the command manager.
//! @details The function binds a command target to the command manager,
//! and add the command manager as a listener.
//! @param target The command target.
static void bindToCommandManager(ApplicationCommandTarget* target);
//! @brief Bind a component to the key mapping set.
static void bindToKeyMapping(juce::Component* target);
//! @brief Get the global ApplicationCommandManager
static juce::ApplicationCommandManager& getCommandManager();
//! @brief Notify command manager that a command status changed
static void commandStatusChanged();
//! @brief Get the command manager key mapping.
static juce::KeyPressMappingSet* getKeyMappings();
//! @brief This must return a complete list of commands that this target can handle.
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
//! @brief This must provide details about one of the commands that this target can perform.
void getCommandInfo(juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
//! @brief This must actually perform the specified command.
bool perform(InvocationInfo const& info) override;
public: // internal methods
KiwiApp() = default;
~KiwiApp() = default;
private: // methods
//! @internal Initialise ressource stuffs at startup
void initResources();
//! @internal Returns true if the App is compatible with a given server version.
bool canConnectToServerVersion(std::string const& server_version);
//! @internal Ping the server to test current connection
//! @brief Called regularly by the App
void pingServer();
//! @internal handle ping succeed
void pingSucceed(std::string const& server_version);
//! @internal handle ping failed
void pingFailed(Api::Error error);
//! @internal Utility to quit the app asynchronously.
class AsyncQuitRetrier;
//! @internal Initializes engine's factory declaring engine objects
void declareEngineObjects();
//! @internal Initializes gui specific objects.
void declareObjectViews();
// @brief Handles changes of server address.
void networkSettingsChanged(NetworkSettings const& settings, juce::Identifier const& ids) override final;
//! @brief Parse startup command line and open file if exists.
void openCommandFile(juce::String const& command_line);
//! @brief Create object help popup menu
void createObjectHelpPopupMenu(juce::PopupMenu& menu);
//! @brief Find help file given an index and open the file.
void findAndOpenHelpFile(int selected_index);
//! @brief Get the list of help files.
juce::Array<juce::File> getSortedObjectHelpFilesInDirectory(juce::File const& directory) const noexcept;
//! @brief Create examples popup menu
void createExamplesPopupMenu(juce::PopupMenu& menu) noexcept;
//! @brief Get the list of example directories.
juce::Array<juce::File> getSortedExampleDirectories() noexcept;
//! @brief Get the list of example files in directory.
juce::Array<juce::File> getSortedExampleFilesInDirectory(juce::File const& directory) const noexcept;
//! @brief Find and launch an example file.
void findAndOpenExample(int selected_index);
private: // members
enum TimerIds : int
{
MainScheduler = 0,
ServerPing,
};
LookAndFeel m_looknfeel;
TooltipWindow m_tooltip_window;
std::unique_ptr<ApiController> m_api_controller = nullptr;
std::unique_ptr<Api> m_api = nullptr;
std::unique_ptr<Instance> m_instance = nullptr;
std::unique_ptr<juce::ApplicationCommandManager> m_command_manager = nullptr;
std::unique_ptr<MainMenuModel> m_menu_model = nullptr;
std::unique_ptr<StoredSettings> m_settings = nullptr;
std::unique_ptr<tool::Scheduler<>> m_scheduler = nullptr;
std::string m_last_server_version_check {};
int m_num_help_files = 0;
int m_num_example_files = 0;
std::map<std::string, juce::File> m_help_aliases {};
};
}
| 14,452
|
C++
|
.h
| 237
| 48.198312
| 114
| 0.570764
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,590
|
KiwiApp_Api.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Network/KiwiApp_Api.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <unordered_set>
#include <set>
#include <KiwiNetwork/KiwiNetwork_Http.h>
#include <json.hpp>
#include <juce_core/juce_core.h>
namespace kiwi
{
using nlohmann::json;
using namespace network;
// ================================================================================ //
// API //
// ================================================================================ //
//! @brief A remote API request handler.
//! @details This class provide helper methods to work with the remote Kiwi REST API.
//! All operations are done asynchronously.
class Api
{
public: // methods
class Controller;
using Session = network::http::Session;
using Response = Session::Response;
class Error;
template<class Type>
using CallbackFn = std::function<void(Type)>;
using Callback = CallbackFn<Session::Response>;
using ErrorCallback = CallbackFn<Api::Error>;
class User;
class AuthUser;
class Folder;
class Document;
using Documents = std::vector<Api::Document>;
using Users = std::vector<Api::User>;
public: // methods
//! @brief Constructor
Api(Api::Controller& controller);
//! @brief Destructor
~Api();
//! @brief Cancels a request.
void cancelRequest(uint64_t request_id);
//! @brief Returns true if the request is currently pending.
bool isPending(uint64_t request_id);
//! @brief Cancel all pending requests.
void cancelAll();
public: // requests
//! @brief Attempt to log-in the user.
//! @param username_or_email user name or email address
//! @param password password
uint64_t login(std::string const& username_or_email,
std::string const& password,
CallbackFn<AuthUser> success_cb,
ErrorCallback error_cb);
//! @brief Attempt to register/signup the user.
//! @param username user name
//! @param email email address
//! @param password password
uint64_t signup(std::string const& username,
std::string const& email,
std::string const& password,
CallbackFn<std::string> success_cb,
ErrorCallback error_cb);
//! @brief Returns a list of users, retrieved with user ids.
uint64_t getUsers(std::unordered_set<uint64_t> const& user_ids, CallbackFn<Api::Users> sucess_cb, ErrorCallback error_cb);
//! @brief Make an async API request to get a list of documents
uint64_t getDocuments(std::function<void(Response, Api::Documents)> callback);
//! @brief Make an async API request to create a new document
//! @param callback
uint64_t createDocument(std::string const& document_name,
std::function<void(Response, Api::Document)> callback);
//! @brief Uploads a document to the server.
uint64_t uploadDocument(std::string const& name,
std::string const& data,
std::string const& kiwi_version,
std::function<void(Response, Api::Document)> callback);
//! @brief Duplicates a document on server side.
uint64_t duplicateDocument(std::string const& document_id, Callback callback);
//! @brief Rename a document asynchronously.
//! @param callback The callback method that will be called when the request is completed.
uint64_t renameDocument(std::string document_id,
std::string const& new_name,
Callback callback);
//! @brief Moves a document to trash.
uint64_t trashDocument(std::string document_id, Callback callback);
//! @brief Moves document out of the trash.
uint64_t untrashDocument(std::string document_id, Callback callback);
//! @brief Returns the open token used to open document.
uint64_t getOpenToken(std::string document_id,
CallbackFn<std::string const&> success_cb,
ErrorCallback error_cb);
//! @brief Make an async API request to download a document.
uint64_t downloadDocument(std::string document_id, Callback success_cb);
//! @brief Retrieve version of kiwi compatible with the api server.
uint64_t getRelease(CallbackFn<std::string const&> success_cb, ErrorCallback error_cb);
//! @brief Requests a reset token to the server.
uint64_t requestPasswordToken(std::string const& user_mail, CallbackFn<std::string const&> success_cb, ErrorCallback error_cb);
//! @brief Sends reset request token to the server.
uint64_t resetPassword(std::string const& token,
std::string const& newpass,
CallbackFn<std::string const&> success_cb,
ErrorCallback error_cb);
public: // helper methods
template<class Type>
static Type getJsonValue(json const& json, std::string const& key, Type default_value = {})
{
return json.count(key) ? json.at(key).get<Type>() : default_value;
}
//! @brief Converts an ISO 8601 received by server.
//! @details Output format is %Y-%m-%d %H:%M:%S
static std::string convertDate(std::string const& date);
private: // methods
//! @brief Kiwi API Endpoints
struct Endpoint
{
static const std::string root;
static const std::string login;
static const std::string documents;
static const std::string users;
static const std::string releases;
static std::string document(std::string const& document_id);
static std::string user(std::string const& user_id);
};
//! @internal Make a new session with pre-filled data.
std::unique_ptr<Session> makeSession(std::string const& endpoint, bool add_auth = true);
//! @internal Store the async future response in a vector
uint64_t storeSession(std::unique_ptr<Session> session);
//! @internal Check if the response header has a JSON content-type
static bool hasJsonHeader(Response const& res);
private: // helper functions
struct comp_session
{
bool operator() (std::unique_ptr<Session> const& lhs,
std::unique_ptr<Session> const& rhs) const
{
return lhs->getId() < rhs->getId();
}
};
private: // variables
Api::Controller& m_controller;
std::set<std::unique_ptr<Session>, comp_session> m_requests;
private: // deleted methods
Api() = delete;
Api(Api const&) = delete;
Api(Api &&) = delete;
Api& operator=(Api const&) = delete;
Api& operator=(Api &&) = delete;
};
// ================================================================================ //
// API ERROR //
// ================================================================================ //
class Api::Error
{
public: // methods
Error();
Error(unsigned status_code, std::string const& message);
Error(Api::Response const& response);
~Error() = default;
unsigned getStatusCode() const;
std::string const& getMessage() const;
private: // members
unsigned m_status_code;
std::string m_message {};
};
// ================================================================================ //
// API USER //
// ================================================================================ //
class Api::User
{
public: // methods
//! @brief Constructor.
User() = default;
virtual ~User() = default;
//! @brief Constructor.
//User& operator = (User && user);
//! @brief Get the user name.
std::string const& getName() const;
//! @brief Get the user email.
std::string const& getEmail() const;
//! @brief Get the user id as a string.
std::string const& getIdAsString() const;
//! @brief Get the user id as an integer.
uint64_t getIdAsInt() const;
//! @brief Get the user api version.
int getApiVersion() const;
//! @brief Returns true if the user has a valid id and email.
bool isValid() const noexcept;
void resetWith(User const& other);
private: // variables
friend void from_json(json const&, Api::User&);
int m_api_version = 0;
std::string m_id {};
std::string m_name {};
std::string m_email {};
//uint64_t m_int_id = 0ull;
//bool m_int_id_need_update_flag = true;
};
//! @brief Helper function to convert an Api::User into a json object
void to_json(json& j, Api::User const& user);
//! @brief Helper function to convert a json object into an Api::User
void from_json(json const& j, Api::User& user);
// ================================================================================ //
// API AUTH USER //
// ================================================================================ //
class Api::AuthUser : public Api::User
{
public: // methods
AuthUser() = default;
AuthUser(User const& other);
AuthUser(AuthUser const& other);
AuthUser(AuthUser && other);
~AuthUser() = default;
void resetWith(AuthUser const& other);
//! @brief Returns true if the user has a token.
//! @see getToken
bool isLoggedIn() const;
//! @brief Returns the user token.
//! @see isLoggedIn()
std::string const& getToken() const;
private: // variables
friend void from_json(json const&, Api::AuthUser&);
friend Api::Controller;
std::string m_token {};
};
//! @brief Helper function to convert an Api::AuthUser into a json object
void to_json(json& j, Api::AuthUser const& user);
//! @brief Helper function to convert a json object into an Api::AuthUser
void from_json(json const& j, Api::AuthUser& user);
// ================================================================================ //
// API DOCUMENT //
// ================================================================================ //
class Api::Document
{
public:
Document() = default;
std::string _id = "0";
std::string name = "";
std::string author_name = "";
juce::Time creation_time {};
bool trashed = false;
juce::Time trashed_time {};
juce::Time opened_time {};
std::string opened_user = "";
uint64_t session_id = 0ul;
//! @brief Returns true if the Document match another Document
bool operator==(Document const& other_doc) const;
};
//! @brief Helper function to convert an Api::Document into a json object
void to_json(json& j, Api::Document const& doc);
//! @brief Helper function to convert a json object into an Api::Document
void from_json(json const& j, Api::Document& doc);
// ================================================================================ //
// API CONTROLLER //
// ================================================================================ //
class Api::Controller
{
public: // methods
//! @brief Constructor
Controller();
//! @brief Constructor
//! @param remote_host The remote host to connect the client to.
//! @param remote_port The remote port to connect the client to.
Controller(std::string const& remote_host, uint16_t remote_port);
virtual ~Controller() = default;
//! @brief Set the host.
void setHost(std::string const& host);
//! @brief Get the host.
std::string const& getHost() const;
//! @brief Set the port.
void setPort(uint16_t port) noexcept;
//! @brief Get the port.
uint16_t getPort() const noexcept;
//! @brief Returns true if the current client api user is logged in.
//! @see logout
bool isUserLoggedIn() const;
//! @brief Returns the authenticated user
Api::AuthUser const& getAuthUser() const;
protected: // methods
//! @brief Clears the token.
//! @details This will clear the stored token.
//! The client will need to login again after this function call to perform authenticated request.
//! @see login, isUserLoggedIn
virtual void clearToken();
protected: // variables
std::string m_host;
uint16_t m_port;
Api::AuthUser m_auth_user;
};
}
| 15,274
|
C++
|
.h
| 301
| 38.704319
| 135
| 0.530804
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,591
|
KiwiApp_DocumentBrowser.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Network/KiwiApp_DocumentBrowser.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Listeners.h>
#include <juce_data_structures/juce_data_structures.h>
#include <juce_events/juce_events.h>
#include "../KiwiApp_Network/KiwiApp_Api.h"
#include "../KiwiApp_General/KiwiApp_StoredSettings.h"
#include "KiwiApp_ApiController.h"
namespace kiwi
{
// ================================================================================ //
// DOCUMENT BROWSER //
// ================================================================================ //
//! @brief Request Patcher document informations through a Kiwi API.
class DocumentBrowser : public juce::Timer
{
public: // nested classes
class Drive;
public: // methods
//! @brief Constructor
DocumentBrowser(std::string const& drive_name, int refresh_time);
//! @brief Destructor
~DocumentBrowser();
//! @brief Sets the drive's name.
void setDriveName(std::string const& name);
//! @brief juce::Timer callback.
void timerCallback() override;
//! @brief Returns a list of drives.
Drive* getDrive() const;
private: // methods
//! @brief Handles request that denied by server.
static void handleDeniedRequest();
private: // variables
std::unique_ptr<Drive> m_distant_drive;
int m_refresh_time;
};
// ================================================================================ //
// DOCUMENT BROWSER DRIVE //
// ================================================================================ //
class DocumentBrowser::Drive
{
public: // nested classes
struct Listener;
class DocumentSession;
using DocumentSessions = std::vector<std::unique_ptr<DocumentSession>>;
private:
using Comp = std::function<bool(DocumentSession const& l_hs, DocumentSession const& r_hs)>;
public: // methods
Drive(std::string const& name);
~Drive() = default;
//! @brief Add a listener.
void addListener(Listener& listener);
//! @brief remove a listener.
void removeListener(Listener& listener);
//! @brief Set the name of this drive.
void setName(std::string const& host);
//! @brief Returns the name of this drive.
std::string const& getName() const;
//! @brief Uploads a document.
//! @detail data is represented as a string
void uploadDocument(std::string const& name, std::string const& data);
//! @brief Creates and opens a new document on this drive.
void createNewDocument(std::string const& document_name);
//! @brief Changes the way documents are sorted.
void setSort(Comp comp);
//! @brief Returns the documents.
DocumentSessions const& getDocuments() const;
//! @brief Returns the documents.
DocumentSessions& getDocuments();
//! @brief Refresh all the document list.
void refresh();
private: // methods
//! @brief Refresh the document list without posting network erors.
void refresh_internal();
private: // members
//! @internal Update the document list (need to be called in the juce Message thread)
void updateDocumentList(Api::Documents docs);
std::string m_name;
DocumentSessions m_documents;
tool::Listeners<Listener> m_listeners;
Comp m_sort;
std::shared_ptr<Drive> m_drive;
bool m_was_connected = false;
friend class DocumentBrowser;
};
// ================================================================================ //
// DOCUMENT BROWSER LISTENER //
// ================================================================================ //
//! @brief Listen to document browser changes.
struct DocumentBrowser::Drive::Listener
{
//! @brief Destructor.
virtual ~Listener() = default;
//! @brief Called when a document session has been added.
virtual void documentAdded(DocumentBrowser::Drive::DocumentSession& doc) {};
//! @brief Called when a document session changed.
virtual void documentChanged(DocumentBrowser::Drive::DocumentSession& doc) {};
//! @brief Called when a document session has been removed.
virtual void documentRemoved(DocumentBrowser::Drive::DocumentSession& doc) {};
//! @brief Called when one or more documents has been added, removed or changed.
virtual void driveChanged() {};
virtual void driveConnectionStatusChanged(bool is_online) {};
};
// ================================================================================ //
// DRIVE DOCUMENT //
// ================================================================================ //
class DocumentBrowser::Drive::DocumentSession
{
public: // methods
//! @brief Constructor.
DocumentSession(DocumentBrowser::Drive& parent, Api::Document document);
//! @brief Destructor.
~DocumentSession();
//! @brief Returns the document drive
Drive& useDrive();
//! @brief Tells the Kiwi instance to open up this document.
void open();
//! @brief Returns the document name
std::string getName() const;
//! @brief Returns the session id of the document.
uint64_t getSessionId() const;
//! @brief Returns the open token of the document.
std::string const& getOpenToken() const;
//! @brief Returns the drive that holds this document.
DocumentBrowser::Drive const& useDrive() const;
//! @brief Rename the document.
void rename(std::string const& new_name);
//! @brief Duplicates the document on server side.
void duplicate();
//! @brief Move the document to trash.
void trash();
// @brief Moves document out of the trash.
void untrash();
//! @brief Called to download the document.
//! @details download is asynchronous and callback is called on the main thread
//! if request succeed.
void download(std::function<void(std::string const&)> callback);
//! @brief Returns the time of the document creation.
juce::Time const& getCreationTime() const;
//! @brief Returns the date creation as a string.
std::string getCreationDate() const;
//! @brief Returns the author's username.
std::string const& getAuthor() const;
//! @brief Returns true if document is trashed
bool isTrashed() const;
//! @brief Returns the trashed time.
juce::Time const& getTrashedTime() const;
//! @brief Returns trashed date as string.
std::string getTrashedDate() const;
//! @brief Returns the last modification time.
juce::Time const& getOpenedTime() const;
//! @brief Returns the last modification date.
std::string getOpenedDate() const;
//! @brief Returns the user that modified document last.
std::string const& getOpenedUser() const;
//! @brief Returns true if the DocumentSession match another DocumentSession
//! @details this operator uses the session_id field to compare.
bool operator==(DocumentSession const& other_doc) const;
private: // members
DocumentBrowser::Drive& m_drive;
Api::Document m_document;
std::string m_open_token;
std::shared_ptr<DocumentSession> m_session;
friend class DocumentBrowser::Drive;
};
}
| 9,450
|
C++
|
.h
| 179
| 42.050279
| 99
| 0.555723
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,592
|
KiwiApp_ApiController.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Network/KiwiApp_ApiController.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Listeners.h>
#include "../KiwiApp_Network/KiwiApp_Api.h"
#include "../KiwiApp_General/KiwiApp_StoredSettings.h"
namespace kiwi
{
class ApiController
: public Api::Controller
{
public: // methods
//! @brief Constructor
ApiController();
//! @brief Destructor
//! @details If the "remember me" flag is true, the user profile will be saved when the object is destroyed.
//! If false, the user profile will be saved whithout the token.
~ApiController();
//! @brief Changes the API's authenticated user.
//! @details All authenticated will now use this user to
//! query the server.
void setAuthUser(Api::AuthUser const& auth_user);
//! @brief Log-out the user.
//! @see login, isUserLoggedIn
void logout();
private: // methods
bool saveAuthUserProfile() const;
bool restoreAuthUserProfile();
};
}
| 1,901
|
C++
|
.h
| 42
| 38.738095
| 116
| 0.607063
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,593
|
KiwiApp_CarrierSocket.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Network/KiwiApp_CarrierSocket.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <functional>
#include "flip/contrib/transport_tcp/CarrierTransportSocketTcp.h"
namespace kiwi
{
// ================================================================================ //
// CARRIER SOCKET //
// ================================================================================ //
//! @brief Class that encapsulate a TCP socket
class CarrierSocket
{
public: // classes
using state_func_t = std::function <void (flip::CarrierBase::Transition, flip::CarrierBase::Error error)>;
using transfer_func_t = std::function <void (size_t, size_t)>;
private: // classes
enum class State
{
Disconnected,
Connecting,
Connected
};
public: // methods
//! @brief Constructor
CarrierSocket(flip::DocumentBase& document);
// @brief Connects the socket to a remote socket
void connect(std::string const& host, uint16_t port, uint64_t session_id, std::string & metadata);
//! @brief Stop the socket from processing and disconnect
void disconnect();
//! @brief Returns true if the socket is connected, false otherwise
bool isConnected() const;
//! @brief Process the socket once
void process();
//! @brief Callback called when transition changes.
void listenStateTransition(state_func_t call_back);
//! @brief Callback called receiving backend informations.
void listenTransferBackend(transfer_func_t call_back);
//! @brief Stops processing
~CarrierSocket();
private: // methods
//! @brief Called when sockets state changed.
void onStateTransition(flip::CarrierBase::Transition transition,
flip::CarrierBase::Error error);
//! @brief Called when the socket receives the backend.
//! @details cur represent the portion that has been downloaded yet. total is the total
//! amount of data that needs to be received.
void onTransferBackend(size_t cur, size_t total);
private: // members
std::unique_ptr<flip::CarrierTransportSocketTcp> m_transport_socket;
flip::DocumentBase & m_document;
State m_state;
state_func_t m_state_func;
transfer_func_t m_transfer_func;
private: // deleted methods
CarrierSocket(CarrierSocket const& other) = delete;
CarrierSocket(CarrierSocket && other) = delete;
CarrierSocket& operator=(CarrierSocket const& other) = delete;
CarrierSocket& operator=(CarrierSocket && other) = delete;
};
}
| 3,913
|
C++
|
.h
| 73
| 43.972603
| 114
| 0.560331
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,594
|
KiwiApp_CommandIDs.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_General/KiwiApp_CommandIDs.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
namespace kiwi
{
// ================================================================================ //
// COMMAND IDs //
// ================================================================================ //
enum CommandIDs
{
newPatcher = 0x200010, ///< Create a new blank patcher window.
newPatcherView = 0x200020, ///< Create a new patcher view.
openFile = 0x200030, ///< Open a file in a new window.
closePatcher = 0x200051, ///< Close the current patcher.
save = 0x200060, ///< Save the current patcher document.
saveAs = 0x200061, ///< Save the current patcher document as.
minimizeWindow = 0x201010, ///< Reduce the current window.
maximizeWindow = 0x201020, ///< Maximise the current window.
closeWindow = 0x201031, ///< Close the current window.
showConsoleWindow = 0x202000, ///< Make visible the "console" window.
showAudioStatusWindow = 0x202010, ///< Make visible the "audio status" window.
showAboutAppWindow = 0x202020, ///< Make visible the "about app" window.
showDocumentation = 0x202025, ///< Show the documentation.
showAppSettingsWindow = 0x202030, ///< Make visible the "application settings" window.
showDocumentBrowserWindow = 0x202040, ///< Make visible the "document browser" window.
showBeaconDispatcherWindow = 0x202050, ///< Make visible the "beacon dispatcher" window.
addBeaconDispatcher = 0x202051, ///< Add a new "beacon dispatcher" element.
removeBeaconDispatcher = 0x202052, ///< Remove a "beacon dispatcher" element.
undo = 0xf1000a, ///< Undo last action.
redo = 0xf1000b, ///< Redo last action.
duplicate = 0xf1000c, ///< Duplicate selected objects and paste them on patcher.
pasteReplace = 0xf1000d, ///< Replace an objects by the one in the clipboard.
toFront = 0xf2000a, ///< Move selected object ahead of all other objects.
toBack = 0xf2000b, ///< Move selected object behind all other objects.
zoomIn = 0xf20013, ///< Magnify the patcher view of almost 10%.
zoomOut = 0xf20014, ///< Reduce the patcher view of almost 10%.
zoomNormal = 0xf20015, ///< Restore the patcher view zoom to 100%.
editModeSwitch = 0xf20100, ///< Toggle Lock/Unlock patcher view.
gridModeSwitch = 0xf20200, ///< Toggle grid patcher mode.
enableSnapToGrid = 0xf20201, ///< Toggle snap to grid patcher mode.
newBox = 0xf30300, ///< Add a new "box" to the patcher.
newMessage = 0xf30301, ///< Add a new "message" object box to the patcher.
newNumber = 0xf30303, ///< Add a new "number" object box to the patcher.
newComment = 0xf30304, ///< Add a new "comment" object box to the patcher.
newBang = 0xf30305, ///< Add a new "button" object box to the patcher.
newToggle = 0xf30306, ///< Add a new "toggle" object box to the patcher.
newSlider = 0xf30307, ///< Add a new "slider" object box to the patcher.
showPatcherInspector = 0xf20400, ///< Shows the patcher properties inspector.
showObjectInspector = 0xf20410, ///< Shows the selected objects properties inspector.
openObjectHelp = 0xf20411, ///< Open selected object help patcher.
switchDsp = 0xf20420, ///< Toggle DSP state
startDsp = 0xf20421, ///< Starts the dsp
stopDsp = 0xf20422, ///< Stops the dsp
scrollToTop = 0xf30001, ///< Scroll to the top
scrollToBottom = 0xf30002, ///< Scroll to the bottom
clearAll = 0xf40001, ///< Clear all content
login = 0xf50000, ///< Log-in the user.
signup = 0xf50010, ///< Register the user.
logout = 0xf50020, ///< Log-out the user.
remember_me = 0xf50030, ///< Toggle the "remember me" option to save user profile.
};
// ================================================================================ //
// COMMAND CATEGORIES //
// ================================================================================ //
namespace CommandCategories
{
static const char* const general = "General";
static const char* const editing = "Editing";
static const char* const view = "View";
static const char* const windows = "Windows";
}
}
| 6,610
|
C++
|
.h
| 84
| 69.97619
| 113
| 0.474023
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,595
|
KiwiApp_IDs.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_General/KiwiApp_IDs.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_core/juce_core.h>
namespace kiwi
{
// ================================================================================ //
// Ids //
// ================================================================================ //
namespace Ids
{
#define DECLARE_ID(name) const juce::Identifier name(#name)
DECLARE_ID(name);
DECLARE_ID(host);
DECLARE_ID(api_port);
DECLARE_ID(session_port);
DECLARE_ID(remember_me);
DECLARE_ID(server_address);
DECLARE_ID(NETWORK_CONFIG);
#undef DECLARE_ID
};
}
| 1,585
|
C++
|
.h
| 34
| 41.029412
| 90
| 0.474069
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,596
|
KiwiApp_StoredSettings.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_General/KiwiApp_StoredSettings.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_data_structures/juce_data_structures.h>
#include <KiwiTool/KiwiTool_Listeners.h>
#include <json.hpp>
namespace kiwi
{
using nlohmann::json;
// ================================================================================ //
// NETWORK SETTINGS //
// ================================================================================ //
class StoredSettings;
class NetworkSettings : juce::ValueTree::Listener
{
public: // methods
//! @brief Constructor
NetworkSettings();
//! @brief Destructor
~NetworkSettings();
//! @brief Reset to default settings values
void resetToDefault();
//! @brief Sets the server adress.
void setServerAddress(std::string const& host, uint16_t api_port, uint16_t session_port);
//! @brief Retrieves a copy of the server adress info.
juce::ValueTree getServerAddress();
//! @brief Restore settings with an xml.
void readFromXml(juce::XmlElement const& xml);
//! @brief Returns the Host as a string
std::string getHost() const;
//! @brief Returns the api port as an integer
uint16_t getApiPort() const;
//! @brief Returns the session port as an integer
uint16_t getSessionPort() const;
//! @brief Returns the session port as an integer
uint16_t getRefreshInterval() const;
void setRememberUserFlag(bool remember_me);
bool getRememberUserFlag() const;
//! @brief NetworkSettings Listener
struct Listener
{
//! @brief Destructor.
virtual ~Listener() = default;
//! @brief Called when the network settings has changed.
virtual void networkSettingsChanged(NetworkSettings const&, juce::Identifier const&) = 0;
};
//! @brief Add a listener.
void addListener(Listener& listener);
//! @brief remove a listener.
void removeListener(Listener& listener);
private: // methods
//! @brief Returns the underlying value tree
juce::ValueTree& use();
void valueTreePropertyChanged(juce::ValueTree&, juce::Identifier const&) override;
void valueTreeChildAdded(juce::ValueTree& parent, juce::ValueTree& child) override;
void valueTreeChildRemoved(juce::ValueTree&, juce::ValueTree&, int) override {}
void valueTreeChildOrderChanged(juce::ValueTree&, int, int) override {}
void valueTreeParentChanged(juce::ValueTree&) override {}
private: // variables
juce::ValueTree m_settings;
tool::Listeners<Listener> m_listeners;
friend StoredSettings;
};
// ================================================================================ //
// STORED SETTINGS //
// ================================================================================ //
//! @brief Settings storage class utility.
class StoredSettings : public juce::ValueTree::Listener
{
public: // methods
//! @brief Constructor.
StoredSettings();
//! @brief Destructor.
~StoredSettings();
//! @brief Returns the global properties file.
juce::PropertiesFile& getGlobalProperties();
//! @brief Flush settings.
void flush();
//! @brief Reload settings.
void reload();
//! @brief Returns the NetworkSettings
NetworkSettings& network();
private: // methods
void saveValueTree(juce::ValueTree const& vt, std::string const& key_name);
void changed();
void valueTreePropertyChanged(juce::ValueTree&, const juce::Identifier&) override { changed(); }
void valueTreeChildAdded(juce::ValueTree&, juce::ValueTree&) override { changed(); }
void valueTreeChildRemoved(juce::ValueTree&, juce::ValueTree&, int) override { changed(); }
void valueTreeChildOrderChanged(juce::ValueTree&, int, int) override { changed(); }
void valueTreeParentChanged(juce::ValueTree&) override { changed(); }
private: // members
std::vector<std::unique_ptr<juce::PropertiesFile>> m_property_files;
NetworkSettings m_network;
private: // deleted methods
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(StoredSettings)
};
StoredSettings& getAppSettings();
juce::PropertiesFile& getGlobalProperties();
juce::PropertiesFile::Options getPropertyFileOptionsFor(juce::String const& filename,
juce::String const& suffix = "settings");
bool saveJsonToFile(juce::String const& filename, json const& j);
json getJsonFromFile(juce::String const& filename);
};
| 6,392
|
C++
|
.h
| 115
| 43.495652
| 107
| 0.557211
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,597
|
KiwiApp_LookAndFeel.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_General/KiwiApp_LookAndFeel.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
namespace kiwi
{
class LookAndFeel
: public juce::LookAndFeel_V4
{
public: // methods
//! @brief Constructor.
LookAndFeel();
//! @brief Destructor.
virtual ~LookAndFeel() = default;
//! @brief Return the default border size of an object.
float getObjectBorderSize() const;
//! @brief Returns the typeface for a certain font name and style.
//! @details LookAndFeel doesn't cache typeface because juce has its own caching mechanism
juce::Typeface::Ptr getTypefaceForFont(juce::Font const& font) override;
//! @brief Overriden to draw a custom PropertyPanel section header
void drawPropertyPanelSectionHeader(juce::Graphics& g,
const juce::String& name,
bool is_open, int width, int height) override;
//! @brief Overriden to draw a custom Table header background.
void drawTableHeaderBackground(juce::Graphics& g, juce::TableHeaderComponent& header) override;
//! @brief Overriden to draw a custom Table header column.
void drawTableHeaderColumn(juce::Graphics& g,
juce::TableHeaderComponent&,
juce::String const& columnName,
int /*columnId*/,
int width, int height,
bool isMouseOver, bool isMouseDown,
int columnFlags) override;
//! @brief Custom Button background drawing
void drawButtonBackground(juce::Graphics& g, juce::Button& b,
juce::Colour const& bgcolor,
bool mouse_over, bool mouse_down) override;
//! @brief Custom Toolbar background drawing
void paintToolbarBackground(juce::Graphics& g, int w, int h, juce::Toolbar& toolbar) override;
//! @brief Custom Toolbar Button background drawing
void paintToolbarButtonBackground(juce::Graphics& g, int /*width*/, int /*height*/,
bool isMouseOver, bool isMouseDown,
juce::ToolbarItemComponent& component) override;
//! @brief Make a textLayout for tootips
static juce::TextLayout layoutTooltipText(juce::String const& text,
juce::Colour colour = juce::Colours::black) noexcept;
private: // deleted methods
//! @brief Set the default Application components colors
void initColours();
private: // variables
float m_box_border_size = 1.f;
LookAndFeel(LookAndFeel const& other) = delete;
LookAndFeel(LookAndFeel && other) = delete;
LookAndFeel& operator=(LookAndFeel const& other) = delete;
LookAndFeel& operator=(LookAndFeel && other) = delete;
};
}
| 4,036
|
C++
|
.h
| 69
| 43.84058
| 103
| 0.580137
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,598
|
KiwiApp_Instance.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_Instance.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Instance.h>
#include <KiwiTool/KiwiTool_Scheduler.h>
#include <juce_events/juce_events.h>
#include "flip/Document.h"
#include "KiwiApp_Console.h"
#include "KiwiApp_SettingsPanel.h"
#include "KiwiApp_DocumentBrowserView.h"
#include "KiwiApp_BeaconDispatcher.h"
#include "../KiwiApp_Patcher/KiwiApp_PatcherManager.h"
#include "../KiwiApp_Audio/KiwiApp_DspDeviceManager.h"
#include "../KiwiApp_Auth/KiwiApp_AuthPanel.h"
namespace kiwi
{
class PatcherViewWindow;
// ================================================================================ //
// INSTANCE //
// ================================================================================ //
//! @brief The Application Instance
class Instance
{
public:
//! @brief Constructor
Instance();
//! @brief Destructor
~Instance();
//! @brief Tick the instance regularly to pull remote document data.
void tick();
//! @brief Get the user ID of the Instance.
uint64_t getUserId() const noexcept;
//! @brief Enables the document browser view.
void login();
//! @brief create a new patcher window.
void newPatcher();
//! @brief Returns the engine::Instance
engine::Instance& useEngineInstance();
//! @brief Returns the engine::Instance
engine::Instance const& useEngineInstance() const;
//! @brief Open a File.
bool openFile(juce::File const& file);
//! @brief Open a patcher from file
void askUserToOpenPatcherDocument();
//! @brief Removes the view of a certain patcher.
void removePatcherWindow(PatcherViewWindow& patcher_window);
//! @brief Attempt to close the given window asking user to save file if needed.
void closeWindow(Window& window);
//! @brief Attempt to close the window with the given id, asking user to save file if needed.
void closeWindowWithId(WindowId window_id);
//! @brief Attempt to close all document, after asking user to save them if needed.
//! @return True if all document have been closed, false if the user cancel the action.
bool closeAllPatcherWindows();
//! @brief Force close all patcher windows.
void forceCloseAllPatcherWindows();
//! @brief Attempt to create a new patcher with document Session informations.
void openRemotePatcher(DocumentBrowser::Drive::DocumentSession& session);
//! @brief Brings the Application settings window to front.
void showAppSettingsWindow();
//! @brief Opens a juce native audio setting pannel.
void showAudioSettingsWindow();
//! @brief Brings the Console to front.
void showConsoleWindow();
//! @brief Brings the Auth form window to front.
void showAuthWindow(AuthPanel::FormType type);
//! @brief Brings the "About Kiwi" window to front.
void showAboutKiwiWindow();
//! @brief Brings the DocumentBrowserWindow to front.
void showDocumentBrowserWindow();
//! @brief Brings the BeaconDispatcherWindow to front.
void showBeaconDispatcherWindow();
//! @brief Get Patcher clipboard data.
std::vector<uint8_t>& getPatcherClipboardData();
//! @internal Handle connection lost.
//! @todo refactor this to handle this event by a callback instead
void handleConnectionLost();
private: // methods
//! @internal pull all documents
//! @brief currently used by the Instance::tick method
void pullRemoteDocuments();
//! @brief Ask the user if he wants to continue to edit document offline
//! @details This could happen if the user logged out or if the connection was lost.
bool askUserToContinueEditingDocumentOffline(PatcherManager& manager,
std::string const& reason) const;
using PatcherManagers = std::vector<std::unique_ptr<PatcherManager>>;
//! @internal get the given patcher manager iterator.
PatcherManagers::iterator getPatcherManager(PatcherManager const& manager);
//! @internal get the given patcher manager iterator.
PatcherManagers::iterator getPatcherManagerForSession(DocumentBrowser::Drive::DocumentSession& session);
//! @internal gets patcher manager currently associated to file.
Instance::PatcherManagers::iterator getPatcherManagerForFile(juce::File const& file);
//! @internal Returns the next untitled number based on current documents
size_t getNextUntitledNumberAndIncrement();
//! @internal Creates the window if needed then the brings it to front.
//! @param create_fn The window factory function.
void showWindowWithId(WindowId id, std::function<std::unique_ptr<Window>()> create_fn);
private: // variables
engine::Instance m_instance;
DocumentBrowser m_browser;
PatcherManagers m_patcher_managers;
sConsoleHistory m_console_history;
std::vector<std::unique_ptr<Window>> m_windows;
std::vector<uint8_t> m_patcher_clipboard;
static size_t m_untitled_patcher_index;
};
}
| 6,910
|
C++
|
.h
| 118
| 46.694915
| 113
| 0.608121
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,599
|
KiwiApp_ConsoleHistory.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_ConsoleHistory.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiEngine/KiwiEngine_Instance.h>
namespace kiwi
{
// ================================================================================ //
// CONSOLE HISTORY //
// ================================================================================ //
//! @brief The Console History listen to the Console and keep an history of the messages.
//! @details It expose methods to fetch messages sorted by date, message or by type.
class ConsoleHistory : public engine::Console::Listener
{
public:
class Listener;
//! @brief Sorting method types
enum Sort
{
ByIndex = 0, ///< Sort messages by Index
ByType, ///< Sort message by type
ByText ///< Sort message by text
};
public:
//! @brief Constructor.
ConsoleHistory(engine::Instance& instance);
//! @brief Destructor.
~ConsoleHistory();
//! @brief Clear the messages.
void clear();
//! @brief Retreives the number of messages in the history.
size_t size();
//! @brief Get a message from the history at a given index.
std::pair<engine::Console::Message const*, size_t> get(size_t index);
//! @brief Erase a message from the history.
//! @param index The index of the message.
void erase(size_t index);
//! @brief Erase a range of messages from the history.
//! @param begin The index of the message of the first message.
//! @param last The index of the message of the last message.
void erase(size_t begin, size_t last);
//! @brief Erase a set of messages from the history.
//! @param indices The indices of the messages
void erase(std::vector<size_t>& indices);
//! @brief Sort the messages by index, type or text.
//! @param sort The type of sorting method.
//! @see History::Sort
void sort(Sort type = ByIndex);
//! @brief Add an history listener.
void addListener(Listener& listener);
//! @brief Remove an history listener.
void removeListener(Listener& listener);
private:
struct MessageHolder
{
engine::Console::Message m_message;
size_t m_index;
size_t m_repeat_times;
};
static bool compareIndex(MessageHolder const& i, MessageHolder const& j);
static bool compareText(MessageHolder const& i, MessageHolder const& j);
static bool compareType(MessageHolder const& i, MessageHolder const& j);
//! @internal Receive the messages from the Console and dispatch changes to listeners.
void newConsoleMessage(engine::Console::Message const& message) final override;
private:
engine::Instance& m_instance;
std::mutex m_message_mutex;
std::vector<MessageHolder> m_messages;
Sort m_sort;
tool::Listeners<Listener> m_listeners;
};
// ================================================================================ //
// INSTANCE LISTENER //
// ================================================================================ //
//! @brief The Console History Listener is a is a virtual class you can inherit from to receive console history change notifications.
class ConsoleHistory::Listener
{
public:
virtual ~Listener() = default;
//! @brief The function is called by an hisotry when it has changed.
//! @param history The console history.
virtual void consoleHistoryChanged(ConsoleHistory const& history) = 0;
};
typedef std::shared_ptr<ConsoleHistory> sConsoleHistory;
typedef std::weak_ptr<ConsoleHistory> wConsoleHistory;
}
| 5,070
|
C++
|
.h
| 97
| 43.051546
| 137
| 0.547484
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,600
|
KiwiApp_SettingsPanel.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_SettingsPanel.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
// ================================================================================ //
// SETTINGS PANEL //
// ================================================================================ //
//! @brief A Panel Component that shows application's settings.
class SettingsPanel : public juce::Component,
public juce::Button::Listener
{
public: // classes
//! @brief Constructor.
SettingsPanel();
//! @brief Destructor.
~SettingsPanel();
private: // methods
//! @brief Resized methods called when resized.
void resized() override final;
//! @brief Called when apply or reset button is clicked.
void buttonClicked(juce::Button * button) override final;
private: // members
juce::ValueTree m_settings;
juce::PropertyPanel m_pannel;
juce::TextButton m_apply_button;
juce::TextButton m_reset_button;
};
}
| 2,086
|
C++
|
.h
| 42
| 41.52381
| 91
| 0.506927
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,601
|
KiwiApp_DocumentBrowserView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_DocumentBrowserView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Listeners.h>
#include "../KiwiApp_Network/KiwiApp_DocumentBrowser.h"
#include "../KiwiApp_Components/KiwiApp_ImageButton.h"
namespace kiwi
{
// ================================================================================ //
// DOCUMENT BROWSER VIEW //
// ================================================================================ //
class DocumentBrowserView : public juce::Component
{
public: // methods
//! @brief Constructor.
DocumentBrowserView(DocumentBrowser& browser, bool enabled);
//! @brief Destructor.
~DocumentBrowserView();
//! @brief Called when resized.
void resized() override;
//! @brief juce::Component::paint
void paint(juce::Graphics& g) override;
private: // methods
void enablementChanged() override final;
private: // nested classes
class DriveView;
private: // members
DocumentBrowser& m_browser;
std::vector<std::unique_ptr<DriveView>> m_drives;
};
// ================================================================================ //
// BROWSER DRIVE VIEW //
// ================================================================================ //
//! @brief Listen to document browser changes.
class DocumentBrowserView::DriveView
: public juce::ListBox
, public juce::ListBoxModel
, public DocumentBrowser::Drive::Listener
{
private: // classes
enum SortBy
{
name,
author,
creationTime,
openedTime
};
struct Comp
{
bool compare(DocumentBrowser::Drive::DocumentSession const& lhs,
DocumentBrowser::Drive::DocumentSession const& rhs) const;
SortBy m_type = SortBy::creationTime;
bool m_trashed_first = false;
std::string m_filter {};
};
public: // methods
//! @brief Constructor.
DriveView(DocumentBrowser::Drive& drive);
//! @brief Destructor.
~DriveView();
//! @brief Returns the session host name.
std::string getHostName() const;
//! @brief Called by the DocumentBrowser::Drive changed.
//! @details Called when one or more document has been changed / removed or added.
void driveChanged() override;
//! @brief Returns the number of items in the list.
int getNumRows() override;
//! @brief Draw a row of the list.
//! @details Note that the rowNumber value may be greater than the number of rows in your
//! list, so be careful that you don't assume it's less than getNumRows().
void paintListBoxItem(int rowNumber, juce::Graphics& g, int width, int height, bool selected) override;
//! @brief Used to create or update a custom component to go in a row of the list.
juce::Component* refreshComponentForRow(int row, bool selected,
juce::Component* component_to_update) override;
//! @brief Called when the user clicking on a part of the list where there are no rows.
void backgroundClicked(juce::MouseEvent const& e) override;
//! @brief Called when the return key is pressed.
void returnKeyPressed(int last_row_selected) override;
//! @brief Called when the user double-clicking on a row.
void listBoxItemDoubleClicked(int row, juce::MouseEvent const& e) override;
//! @brief Opens document for the given row.
void openDocument(int row);
//! @brief Make an API call to duplicate the document on server side.
void duplicateDocumentForRow(int row);
//! @brief Make an API call to rename the remote document
void renameDocumentForRow(int row, std::string const& new_name);
//! @brief Makes an API call to upload a document.
void uploadDocument();
//! @brief Makes an API call to download the remote document.
void downloadDocumentForRow(int row);
//! @brief Moves a document to trash.
void deleteDocumentForRow(int row);
//! @brief Restore a trashed document.
void restoreDocumentForRow(int row);
std::vector<DocumentBrowser::Drive::DocumentSession*> getDisplayedDocuments();
DocumentBrowser::Drive::DocumentSession* getDocumentForRow(int row);
private: // methods
//! @brief Hides document list and disable some interactions.
void enablementChanged() override;
//! @brief Resort content and call update content.
void update();
//! @brief Returns the drive name.
std::string const& getDriveName() const;
//! @brief Refresh document list.
void refresh();
//! @brief Creates a new document.
void createDocument();
//! @brief Returns the current sorting parameter.
SortBy getSortType() const;
//! @brief Changes the sort parameter and sorts.
void setSortType(SortBy sort_type);
//! @brief Suggests documents based on text input compared to documents name
void setFilter(std::string const& text);
// @brief Set the trash mode.
void setTrashMode(bool trash_mode);
//! @brief Get current mode trash or default.
bool isShowingTrashedDocuments() const;
//! @brief Creates document info tooltip.
std::string createDocumentToolTip(DocumentBrowser::Drive::DocumentSession const& doc);
//! @brief Save the state of the component
void saveState();
//! @brief Restore the state of the component
void restoreState();
private: // classes
class Header;
class RowElem;
private: // members
DocumentBrowser::Drive& m_drive;
std::string m_name;
bool m_trash_mode;
bool m_enabled;
Comp m_sorter;
};
// ================================================================================ //
// BROWSER DRIVE VIEW HEADER //
// ================================================================================ //
class DocumentBrowserView::DriveView::Header
: public juce::Component
, public juce::TextEditor::Listener
{
public: // methods
//! @brief Constructor
Header(DocumentBrowserView::DriveView& drive_view);
//! @brief Destructor
~Header() = default;
//! @brief juce::Component::paint
void paint(juce::Graphics& g) override;
//! @brief juce::Component::resized
void resized() override;
//! @brief juce::Component::mouseDown
void mouseDown(juce::MouseEvent const& event) override;
//! @brief Sets the text diaplyed by the header bar.
void setText(std::string const& text);
/** Show or hide toolbar */
void showSearchBar(bool show);
private: // methods
void enablementChanged() override;
/** Called when the user changes the text in some way. */
void textEditorTextChanged (juce::TextEditor&) override;
/** Called when the user presses the return key. */
void textEditorReturnKeyPressed (juce::TextEditor&) override {}
/** Called when the user presses the escape key. */
void textEditorEscapeKeyPressed (juce::TextEditor&) override;
/** Called when the text editor loses focus. */
void textEditorFocusLost (juce::TextEditor&) override {}
private: // members
DocumentBrowserView::DriveView& m_drive_view;
int m_toolbar_thickness = 50;
ImageButton m_refresh_btn;
ImageButton m_create_document_btn;
ImageButton m_trash_btn;
ImageButton m_search_btn;
juce::Rectangle<int> m_folder_bounds;
juce::Label m_label;
juce::Image m_folder_img;
juce::Image m_disable_folder_img;
juce::TextEditor m_searchbar;
};
// ================================================================================ //
// BROWSER DRIVE VIEW ROW ELEM //
// ================================================================================ //
class DocumentBrowserView::DriveView::RowElem : public juce::Component,
public juce::SettableTooltipClient,
public juce::Label::Listener
{
public: // methods
//! @brief Constructor.
RowElem(DriveView& drive_view, std::string const& name, std::string const& tooltip);
//! @brief Destructor.
~RowElem();
//! @brief Show the document name editor.
void showEditor();
//! @brief juce::Component::paint
void paint(juce::Graphics& g) override;
//! @brief Called when resized.
void resized() override;
//! @brief juce::Component::mouseEnter
void mouseEnter(juce::MouseEvent const& event) override;
//! @brief juce::Component::mouseExit
void mouseExit(juce::MouseEvent const& event) override;
//! @brief juce::Component::mouseDown
void mouseDown(juce::MouseEvent const& event) override;
//! @brief juce::Component::mouseUp
void mouseUp(juce::MouseEvent const& event) override;
//! @brief juce::Component::mouseDoubleClick
void mouseDoubleClick(juce::MouseEvent const& event) override;
//! @brief Called when a Label's text has changed.
void labelTextChanged(juce::Label* label_text_that_has_changed) override;
//! @brief Update the document session
void update(std::string const& name, std::string const& tooltip, int row, bool now_selected);
private: // methods
void showPopup();
private: // variables
DriveView& m_drive_view;
std::string m_name;
juce::Label m_name_label;
ImageButton m_open_btn;
const juce::Image m_kiwi_filetype_img;
int m_row = -1;
bool m_selected;
bool m_mouseover = false;
};
}
| 12,328
|
C++
|
.h
| 235
| 40.680851
| 111
| 0.554512
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,602
|
KiwiApp_Console.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_Console.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include "../KiwiApp_Components/KiwiApp_Window.h"
#include "KiwiApp_ConsoleHistory.h"
namespace kiwi
{
class Console;
// ================================================================================ //
// CONSOLE CONTENT COMPONENT //
// ================================================================================ //
//! @brief The juce ConsoleContent Component
//! @details The juce Console Component maintain a ConsoleHistory and display Console messages to the user.
//! The user can select a message to copy it to the system clipboard, delete a specific message or a range of messages, sort messages, double-click on a row to hilight the corresponding object...
class ConsoleContent
: public ConsoleHistory::Listener
, public juce::Component
, public juce::TableListBoxModel
, public juce::TableHeaderComponent::Listener
, public juce::FileDragAndDropTarget
{
public:
//! @brief Constructor
ConsoleContent(sConsoleHistory history);
//! @brief Destructor
~ConsoleContent();
//! @brief Gets the ConsoleHistory.
sConsoleHistory getHistory();
//! @brief The function is called by an hisotry when it has changed.
//! @param history The console history.
void consoleHistoryChanged(ConsoleHistory const& history) final override;
// ================================================================================ //
// COMPONENT //
// ================================================================================ //
void resized() override;
void paint(juce::Graphics& g) override;
// ================================================================================ //
// TABLE LIST BOX MODEL //
// ================================================================================ //
//! @brief Called when selected rows changed.
void selectedRowsChanged(int row) override;
//! @brief Called when the delete key has been pressed.
void deleteKeyPressed(int lastRowSelected) override;
//! @brief Get the number of rows currently displayed by the console
int getNumRows() override;
//! @brief Get the number of selected rows.
int getNumSelectedRows() const;
//! @brief This is overloaded from TableListBoxModel, and should fill in the background of the whole row
void paintRowBackground(juce::Graphics& g,
int rowNumber, int width, int height,
bool rowIsSelected) override;
//! @brief Paint over cells.
void paintOverChildren(juce::Graphics &g) override;
//! @brief Called when the console background has been clicked (clear row selection).
void backgroundClicked(const juce::MouseEvent& mouse) override;
//! @brief This must paint any cells that aren't using custom components.
void paintCell(juce::Graphics& g,
int rowNumber, int columnId,
int width, int height,
bool rowIsSelected) override;
//! @brief This is overloaded from TableListBoxModel,
//! @details Called when the user has clicked a table header to change the sort order.
void sortOrderChanged(int newSortColumnId, bool isForwards) override;
//! @brief Called when a cell is double-clicked,
void cellDoubleClicked(int rowNumber, int columnId, const juce::MouseEvent& mouse) override;
//! @brief This is overloaded from TableListBoxModel
//! @details Must update any custom components that we're using
Component* refreshComponentForCell(int rowNumber,
int columnId,
bool isRowSelected,
juce::Component* existingComponentToUpdate) override;
//! @brief This is overloaded from TableListBoxModel.
//! @details Should choose and return the best width for the specified column.
int getColumnAutoSizeWidth(int columnId) override;
//! @brief Scroll the list to the top.
void scrollToTop();
//! @brief Scroll the list to the bottom.
void scrollToBottom();
//! @brief Clear all the console content.
void clearAll();
// ================================================================================ //
// FileDragAndDropTarget //
// ================================================================================ //
bool isInterestedInFileDrag(juce::StringArray const& files) override;
void fileDragEnter(juce::StringArray const&, int, int) override;
void fileDragExit(juce::StringArray const&) override;
void filesDropped(juce::StringArray const& files, int x, int y) override;
// ================================================================================ //
// TABLE HEADER COMPONENT LISTENER //
// ================================================================================ //
//! @brief This is called when one or more of the table's columns are resized.
void tableColumnsResized(juce::TableHeaderComponent* tableHeader) override;
//! @brief This is called when some of the table's columns are added, removed, hidden, or rearranged.
void tableColumnsChanged(juce::TableHeaderComponent* tableHeader) override {};
//! @brief This is called when the column by which the table should be sorted is changed.
void tableSortOrderChanged(juce::TableHeaderComponent* tableHeader) override {};
//! @brief This is called when the rightmost column width need to be updated.
void updateRighmostColumnWidth(juce::TableHeaderComponent* header);
private:
//! @internal Column type
enum Column
{
Message = 1
};
//! @internal copy selected rows content.
void copy();
//! @internal erase selected rows.
void erase();
private:
wConsoleHistory m_history;
juce::Font m_font;
juce::TableListBox m_table;
bool m_is_dragging_over {false};
friend class Console;
};
// ================================================================================ //
// CONSOLE TOOLBAR //
// ================================================================================ //
class ConsoleToolbarFactory : public juce::ToolbarItemFactory
{
public: // methods
//! @brief Constructor.
ConsoleToolbarFactory();
enum ItemIds
{
clear = 1,
scroll_to_top = 2,
scroll_to_bottom = 3,
};
void getAllToolbarItemIds(juce::Array<int>& ids) override;
void getDefaultItemSet(juce::Array<int>& ids) override;
juce::ToolbarItemComponent* createItem(int itemId) override;
private: // variables
};
// ================================================================================ //
// CONSOLE COMPONENT //
// ================================================================================ //
class Console : public juce::Component, public juce::ApplicationCommandTarget
{
public: // methods
//! @brief Constructor
Console(sConsoleHistory history);
//! @brief juce::Component::resized
void resized() override;
//! @brief juce::Component::paint
void paint(juce::Graphics& g) override;
// ================================================================================ //
// APPLICATION COMMAND TARGET //
// ================================================================================ //
juce::ApplicationCommandTarget* getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
void getCommandInfo(juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform(const InvocationInfo& info) override;
private: // variables
ConsoleContent m_console;
juce::Toolbar m_toolbar;
ConsoleToolbarFactory m_toolbar_factory;
};
}
| 10,205
|
C++
|
.h
| 172
| 47.930233
| 199
| 0.511474
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,603
|
KiwiApp_BeaconDispatcher.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_BeaconDispatcher.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Atom.h>
#include <KiwiEngine/KiwiEngine_Instance.h>
#include "../KiwiApp_Components/KiwiApp_Window.h"
namespace kiwi
{
class BeaconDispatcher;
// ================================================================================ //
// BEACON DISPATCHER //
// ================================================================================ //
//! @brief A Component that allows to dispatch messages to Beacon::Castaway objects.
class BeaconDispatcherElem : public juce::Component, public juce::Button::Listener, juce::Slider::Listener
{
public: // methods
//! @brief Constructor.
BeaconDispatcherElem(engine::Instance& instance);
//! @brief Destructor.
~BeaconDispatcherElem();
//! @brief Called when resized.
void resized() override;
//! @brief juce::Component.
void paint(juce::Graphics& g) override;
//! @brief Called when the button is clicked.
void buttonClicked(juce::Button*) override;
//! @brief Set the background colour.
void setBackgroundColor(juce::Colour const& color);
void restoreState(juce::XmlElement* saved_state);
void saveState(juce::XmlElement* saved_state);
private: // methods
class TextValueComponent : public juce::Component, public juce::Button::Listener
{
public:
TextValueComponent(BeaconDispatcherElem& owner);
~TextValueComponent();
void buttonClicked(juce::Button*) override;
void resized() override;
private:
BeaconDispatcherElem& m_owner;
juce::TextEditor m_message_editor;
juce::TextButton m_send_button;
};
//! @brief dispatch message to castaways
void sendValue(std::vector<tool::Atom> const& args) const;
//! @brief dispatch message to castaways
void send(std::string const& name, std::vector<tool::Atom> const& args) const;
//! @brief Called when a slider value changed.
void sliderValueChanged(juce::Slider* slider) override;
private: // members
engine::Instance& m_instance;
juce::TextEditor m_beacon_name_editor;
TextValueComponent m_text_value;
juce::Slider m_message_slider;
juce::ToggleButton m_toggle_value;
juce::TabbedComponent m_message_tab;
juce::Colour m_bgcolor;
};
// ================================================================================ //
// CONSOLE TOOLBAR //
// ================================================================================ //
class BeaconDispatcherToolbarFactory : public juce::ToolbarItemFactory
{
public: // methods
//! @brief Constructor.
BeaconDispatcherToolbarFactory();
enum ItemIds
{
addItem = 1,
removeItem = 2,
};
void getAllToolbarItemIds(juce::Array<int>& ids) override;
void getDefaultItemSet(juce::Array<int>& ids) override;
juce::ToolbarItemComponent* createItem(int itemId) override;
};
// ================================================================================ //
// BEACON DISPATCHER //
// ================================================================================ //
class BeaconDispatcher : public juce::Component, public juce::ApplicationCommandTarget
{
public: // methods
//! @brief Constructor.
BeaconDispatcher(engine::Instance& instance);
//! @brief Destructor.
~BeaconDispatcher();
//! @brief Called when resized.
void resized() override;
void addElem();
void removeElem();
bool restoreState();
void saveState();
// ================================================================================ //
// APPLICATION COMMAND TARGET //
// ================================================================================ //
juce::ApplicationCommandTarget* getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
void getCommandInfo(juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform(const InvocationInfo& info) override;
private: // variables
void updateLayout();
engine::Instance& m_instance;
std::vector<std::unique_ptr<BeaconDispatcherElem>> m_components;
juce::Toolbar m_toolbar;
BeaconDispatcherToolbarFactory m_toolbar_factory;
int m_elem_height = 100;
};
}
| 6,270
|
C++
|
.h
| 119
| 42.571429
| 110
| 0.509405
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,604
|
KiwiApp_AboutWindow.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Application/KiwiApp_AboutWindow.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include "../KiwiApp_Components/KiwiApp_Window.h"
namespace kiwi
{
// ================================================================================ //
// ABOUT WINDOW //
// ================================================================================ //
//! @brief Kiwi About window.
//! @details Displays application informations.
class AboutWindow : public Window
{
public: // methods
//! @brief Constructor.
AboutWindow();
//! @brief Destructor.
~AboutWindow() = default;
private: // classes
class Content;
private: // variables
};
//! @brief A list of HyperlinkButtons with optional description.
class LinkList : public juce::Component
{
public: // methods
struct Link {
Link(juce::String text, juce::URL url, juce::String _description = "")
: link(text, url)
, description("description", _description)
{}
Link(Link const& rhs)
: link(rhs.link.getButtonText(), rhs.link.getURL())
, description("description", rhs.description.getText())
{}
Link(Link&&) = default;
juce::HyperlinkButton link = {};
juce::Label description = {};
};
//! @brief Constructor.
LinkList(juce::String header, std::vector<Link> links);
//! @brief Destructor.
~LinkList() = default;
//! @brief juce::Component
void resized() override;
private: // variables
juce::Label m_header = {};
std::vector<Link> m_links;
};
class AboutWindow::Content : public juce::Component
{
public: // methods
//! @brief Constructor.
Content();
//! @brief Destructor.
~Content() = default;
//! @brief juce::Component
void paint(juce::Graphics& g) override;
//! @brief juce::Component
void resized() override;
private: // variables
juce::Image m_kiwi_app_image;
LinkList m_authors_links;
LinkList m_credits_links;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Content)
};
}
| 3,492
|
C++
|
.h
| 80
| 32.675
| 91
| 0.515113
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,605
|
KiwiApp_FormComponent.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_FormComponent.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
// ================================================================================ //
// ALERT BOX //
// ================================================================================ //
class AlertBox
: public juce::Component
, private juce::Button::Listener
{
public: // methods
enum class Type : uint8_t
{
Info = 0,
Success = 1,
Error = 2
};
//! @brief Constructor.
AlertBox(std::string const& message,
Type type = Type::Info,
bool can_cancel = true,
std::function<void(void)> on_close = nullptr);
//! @brief Destructor.
~AlertBox();
private: // methods
//! @internal paint method
void paint(juce::Graphics&) override;
//! @internal resized method
void resized() override;
//! @internal juce::ButtonListener
void buttonClicked(juce::Button*) override;
private: // variables
std::string m_message;
Type m_type = Type::Info;
std::unique_ptr<juce::TextButton> m_close_btn;
std::function<void(void)> m_close_fn;
};
// ================================================================================ //
// FORM COMPONENT //
// ================================================================================ //
class FormComponent
: public juce::Component
, private juce::Button::Listener
{
public: // methods
class Field;
//! @brief Constructor.
//! @details Creates a login form.
FormComponent(std::string const& submit_button_text,
std::string const& overlay_text = "");
//! @brief Destructor.
virtual ~FormComponent();
//! @brief This is called when the form is dismissed
//! @details (either cancelled or when registration succeeds).
virtual void dismiss();
//! @brief Computes and returns the best height for this form.
//! @details It will be based on the number of fields and form components.
int getBestHeight();
protected: // methods
//! @brief Add a new field.
template<class FieldType, class... Args>
FieldType& addField(Args&&... args);
//! @brief Returns a field Value.
juce::Value getFieldValue(std::string const& name);
//! @brief Remove fields by name.
void removeField(std::string const& name);
//! @brief Remove all fields.
void clearFields();
//! @brief Show an Alert on the top of the form;
void showAlert(std::string const& message,
AlertBox::Type type = AlertBox::Type::Error);
//! @brief Show overlay
void showOverlay();
//! @brief Show success overlay
void showSuccessOverlay(juce::String const& message);
//! @brief Hide overlay
void hideOverlay();
//! @brief Changes the submit button text
void setSubmitText(std::string const& submit_text);
//! @brief Returns true if the overlay component is visible.
bool hasOverlay();
//! @brief Called when the user clicked the submit button.
//! @details Subclasses need to override this to perform form submission.
virtual void onUserSubmit() = 0;
//! @brief Called when the user clicked the cancel button.
//! @details The default implementation will call the dismiss() method,
//! Subclasses can override this to react to the user cancel action.
virtual void onUserCancelled();
//! @internal resized method
void resized() override;
//! @brief Returns the height of all fields
int getFieldsHeight();
private: // methods
//! @internal paint method
void paint(juce::Graphics&) override final;
void buttonClicked(juce::Button*) override;
juce::Rectangle<int> getButtonArea() const;
private: // variables
std::string m_overlay_text;
juce::TextButton m_submit_btn, m_cancel_btn;
std::unique_ptr<AlertBox> m_alert_box;
std::vector<std::unique_ptr<Field>> m_fields;
int m_alert_height;
class OverlayComp;
friend class OverlayComp;
Component::SafePointer<OverlayComp> m_overlay;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FormComponent)
};
// ================================================================================ //
// FORM COMPONENT FIELD //
// ================================================================================ //
class FormComponent::Field : public juce::Component
{
public: // methods
class SingleLineText;
class Password;
class ToggleButton;
class KiwiLogo;
class TextButton;
Field(std::string name);
virtual ~Field() = default;
std::string const& getName() const;
virtual juce::Value& getValue() = 0;
virtual int getPreferedHeight();
private: // variables
std::string m_name;
};
// ================================================================================ //
// SINGLE LINE FIELD //
// ================================================================================ //
class FormComponent::Field::SingleLineText : public Field
{
public: // methods
SingleLineText(std::string name, std::string text, std::string placeholder_text);
virtual ~SingleLineText() = default;
juce::Value& getValue() override;
void resized() override;
protected: // variables
juce::TextEditor m_text_editor;
};
// ================================================================================ //
// PASWWORD FIELD //
// ================================================================================ //
class FormComponent::Field::Password : public SingleLineText
{
public: // methods
Password(std::string name, std::string text, std::string placeholder_text);
~Password() = default;
};
// ================================================================================ //
// TOGGLE BUTTON FIELD //
// ================================================================================ //
class FormComponent::Field::ToggleButton : public Field
{
public: // methods
ToggleButton(std::string name, std::string text, bool _default = false);
~ToggleButton() = default;
juce::Value& getValue() override;
void resized() override;
int getPreferedHeight() override;
private: // variables
juce::ToggleButton m_button;
};
// ================================================================================ //
// TEXT BUTTON FIELD //
// ================================================================================ //
class FormComponent::Field::TextButton : public Field, public juce::Button::Listener
{
public:
TextButton(std::string const& name,
std::string const& buton_text,
std::function<void()> call_back);
~TextButton();
juce::Value& getValue() override final;
int getPreferedHeight() override final;
void resized() override;
void buttonClicked(juce::Button *) override final;
private:
juce::TextButton m_button;
juce::Value m_value;
std::function<void()> m_call_back;
};
// ================================================================================ //
// KIWI LOGO FIELD //
// ================================================================================ //
class FormComponent::Field::KiwiLogo : public Field
{
public: // methods
KiwiLogo();
~KiwiLogo() = default;
void paint(juce::Graphics& g) override;
juce::Value& getValue() override;
int getPreferedHeight() override;
private: // variables
juce::Image m_kiwi_app_image;
juce::Value m_useless_value;
};
// ================================================================================ //
// FORM COMPONENT - template definitions //
// ================================================================================ //
template<class FieldType, class... Args>
FieldType& FormComponent::addField(Args&&... args)
{
auto field = std::make_unique<FieldType>(std::forward<Args>(args)...);
addAndMakeVisible(*field);
auto it = m_fields.emplace(m_fields.end(), std::move(field));
return dynamic_cast<FieldType&>(*(it->get()));
}
}
| 10,999
|
C++
|
.h
| 224
| 38.09375
| 90
| 0.473716
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,606
|
KiwiApp_Window.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_Window.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
namespace kiwi
{
// ================================================================================ //
// WINDOW //
// ================================================================================ //
//! @brief Common interface for all windows held by the application.
class Window : public juce::DocumentWindow, public juce::ApplicationCommandTarget
{
public: // methods
//! @brief Constructor.
//! @details Setup the window and restore its state from stored settings it they exist.
//! @param content A component that will be owned and displayed by the window
//! @param resizable Pass true to make a resizable window.
//! @param is_main_window see isMainWindow()
//! @param settings_name The name of the window settings
//! (pass an empty string if you dont want to save the window state)
//! @param add_menubar Pass true to add the kiwi application menubar to the window
Window(std::string const& name,
std::unique_ptr<juce::Component> content,
bool resizable = false,
bool is_main_window = true,
juce::String settings_name = "",
bool add_menubar = false);
//! @brief Window destructor. Called whenever buttonPressed is called.
//! @details Will store position into settings if needed.
virtual ~Window();
//! @brief Return true if window shall be a main window of kiwi.
//! @details On windows platform, the application quit when all main windows are closed.
bool isMainWindow() const;
//! @brief Restore the window state
//! @details If the settings name you passed in the ctor is not empty,
//! the function will try to read and apply these settings.
//! @see saveWindowState
void restoreWindowState();
//! @brief Save the window state
//! @details If the settings name you passed in the ctor is not empty,
//! the function will save window state.
//! @see restoreWindowState
void saveWindowState();
//! @brief Close the window.
void close();
// ================================================================================ //
// APPLICATION COMMAND TARGET //
// ================================================================================ //
ApplicationCommandTarget* getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
void getCommandInfo(const juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform(InvocationInfo const& info) override;
protected: // methods
//! @brief Called when close button is pressed. Request instance to close the window.
void closeButtonPressed() override;
private: // variables
juce::String m_settings_name {};
bool m_is_main_window {false};
};
//! @brief Singleton application window's ids
//! @see Instance::showWindowWithId
enum class WindowId : std::size_t
{
Console = 0,
FormComponent,
AboutKiwi,
DocumentBrowser,
ApplicationSettings,
AudioSettings,
BeaconDispatcher,
count // Number of WindowIds
};
}
| 4,646
|
C++
|
.h
| 85
| 44.8
| 109
| 0.543434
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,607
|
KiwiApp_CustomToolbarButton.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_CustomToolbarButton.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
//! @brief A type of button designed to go on a toolbar.
//! @details This class is a modified version of the juce::ToolbarButton class.
//! @see juce::ToolbarButton, ToolbarItemFactory
class CustomToolbarButton : public juce::ToolbarItemComponent
{
public: // methods
//! @brief Constructor.
//! @param itemId the ID for this toolbar item type. This is passed through to the
//! ToolbarItemComponent constructor
//! @param labelText the text to display on the button(if the toolbar is using a style
//! that shows text labels). This is passed through to the
//! ToolbarItemComponent constructor
//! @param normalImage a drawable object that the button should use as its icon. The object
//! that is passed-in here will be kept by this object and will be
//! deleted when no longer needed or when this button is deleted.
//! @param toggledOnImage a drawable object that the button can use as its icon if the button
//! is in a toggled-on state(see the Button::getToggleState() method). If
//! nullptr is passed-in here, then the normal image will be used instead,
//! regardless of the toggle state. The object that is passed-in here will be
//! owned by this object and will be deleted when no longer needed or when
//! this button is deleted.
CustomToolbarButton(int itemId,
const juce::String& labelText,
const juce::Colour bgcolor,
juce::Drawable* normalImage,
juce::Drawable* toggledOnImage);
//! @brief Destructor.
~CustomToolbarButton();
//! @internal
bool getToolbarItemSizes(int toolbarDepth, bool isToolbarVertical, int& preferredSize,
int& minSize, int& maxSize) override;
//! @internal
void paintButtonArea(juce::Graphics&, int width, int height, bool isMouseOver, bool isMouseDown) override;
//! @internal
void contentAreaChanged(const juce::Rectangle<int>&) override;
//! @internal
void buttonStateChanged() override;
//! @internal
void resized() override;
//! @internal
void enablementChanged() override;
private: // variables
juce::ScopedPointer<juce::Drawable> normalImage, toggledOnImage;
juce::Drawable* currentImage;
const juce::Colour m_bgcolor;
void updateDrawable();
juce::Drawable* getImageToUse() const;
void setCurrentImage(juce::Drawable*);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CustomToolbarButton)
};
}
| 3,746
|
C++
|
.h
| 69
| 44.695652
| 115
| 0.615279
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,608
|
KiwiApp_SuggestEditor.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_SuggestEditor.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Listeners.h>
#include <juce_core/juce_core.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiApp_Utils/KiwiApp_SuggestList.h>
namespace kiwi
{
// ================================================================================ //
// SUGGEST EDITOR //
// ================================================================================ //
//! @brief A text editor with auto-completion.
//! @details This component shows a dropdown menu list below it.
class SuggestEditor
: public juce::TextEditor,
public juce::TextEditor::Listener
{
public: // methods
//! @brief Constructor.
//! @param entries Populate suggestion list with these entries.
SuggestEditor(SuggestList::entries_t entries);
//! @brief Destructor.
~SuggestEditor();
private: // methods
//! @brief Shows the menu.
void showMenu();
//! @brief Returns true if the menu is currently opened.
bool isMenuOpened() const noexcept;
//! @brief Close the menu.
void closeMenu();
//! @brief juce::TextEditor.
bool keyPressed(juce::KeyPress const& key) override;
//! @brief Called when a key status changed.
bool keyStateChanged(bool isKeyDown) override;
//! @brief juce::TextEditor::Listener
void textEditorTextChanged(juce::TextEditor& ed) override;
//! @brief juce::TextEditor::Listener.
//! @details Needs to hide menu when focus is lost on editor.
void textEditorFocusLost(juce::TextEditor & editor) override;
//! @brief Called when a menu item has been clicked.
void menuItemSelected(juce::String const& text);
//! @brief Called whenever a selected item is validated.
void menuItemValidated(juce::String const& text);
//! @brief Called whenever the selected item is unselected.
//! @details Replace suggestion with what was fomerly typed.
void menuItemUnselected();
//! @brief Causes the sugesst list to stop updating.
void disableUpdate();
//! @brief Causes the suggest list to start updating.
void enableUpdate();
private: // classes
class Menu;
private: // members
SuggestList m_suggest_list;
juce::StringArray m_split_text;
std::unique_ptr<Menu> m_menu = nullptr;
bool m_update_enabled;
};
// ================================================================================ //
// MENU //
// ================================================================================ //
//! @brief Suggestion menu.
class SuggestEditor::Menu : public juce::Component, public juce::ListBoxModel
{
public: // methods
using action_method_t = std::function<void(juce::String)>;
//! @brief Constructor.
Menu(SuggestList& list, SuggestEditor & creator);
//! @brief Destructor.
~Menu();
//! @brief Set the action to execute when an item has been double-clicked.
void setItemValidatedAction(action_method_t function);
//! @brief Set the action to execute when an item has been selected.
void setSelectedItemAction(action_method_t function);
//! @brief Set the action to execute when item are unselected.
void setUnselectedItemAction(std::function<void(void)> function);
//! @brief Unselect the currently selected row
void unselectRow();
//! @brief Select an item of the list.
void selectRow(int idx);
//! @brief Select the first item of the list.
void selectFirstRow();
//! @brief Select the previous item of the list.
void selectPreviousRow();
//! @brief Select the next item of the list.
void selectNextRow();
//! @brief Called to validate the current selected row.
void validateSelectedRow();
//! @brief Update the list.
void update();
// juce::Component
void paint(juce::Graphics& g) override;
// juce::Component
void resized() override;
//! @brief Returns the curretly selected row
int getSelectedRow() const;
private: // methods
//! @brief Returns true if suggest editor creator is target component.
//! @details Called only for keypressed events not for mouse events.
bool canModalEventBeSentToComponent(juce::Component const* target_component) override final;
//! @brief Exists modal state if click happens.
//! @details If the creator is clicked it sets the caret visible enabling edition
//! otherwise it exits modal state. Called only on mouse clicks events.
void inputAttemptWhenModal() override final;
// ================================================================================ //
// SUGGEST LISTBOX MODEL //
// ================================================================================ //
//! @brief Returns the number of items in the list.
int getNumRows() override;
//! @brief Draw a row of the list.
void paintListBoxItem(int row_number, juce::Graphics& g,
int width, int height, bool selected) override;
//! @brief User clicked on a row.
void listBoxItemClicked(int row, juce::MouseEvent const& e) override;
//! @brief User double-clicked on a row.
void listBoxItemDoubleClicked(int row, juce::MouseEvent const& e) override;
//! @brief Called when rows are selected or deselected.
void selectedRowsChanged(int last_row_selected) override;
private: // members
SuggestList& m_suggest_list;
juce::ListBox m_suggest_list_box;
SuggestEditor & m_creator;
juce::ComponentBoundsConstrainer m_constrainer;
juce::ResizableCornerComponent m_resizable_corner;
action_method_t m_validated_action;
action_method_t m_selected_action;
std::function<void(void)> m_unselected_action;
};
}
| 7,775
|
C++
|
.h
| 142
| 44.246479
| 100
| 0.558062
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,609
|
KiwiApp_TooltipWindow.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_TooltipWindow.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
// ================================================================================ //
// CUSTOM TOOLTIP CLIENT //
// ================================================================================ //
//! @brief A custom tooltip client that provides the bounds of the tooltip to show.
class CustomTooltipClient : public juce::TooltipClient
{
public:
//! @brief Destructor.
virtual ~CustomTooltipClient() = default;
//! @brief Returns the bounds of the tooltip to show.
virtual juce::Rectangle<int> getTooltipBounds(juce::String const& tip,
juce::Point<int> pos,
juce::Rectangle<int> parent_area,
int width,
int height) = 0;
//! @brief Can be overriden to provide a custom drawing method.
virtual bool drawTooltip(juce::Graphics& g,
juce::String const& text,
int width, int height);
};
// ================================================================================ //
// CUSTOM TOOLTIP WINDOW //
// ================================================================================ //
//! @brief A custom TooltipWindow
//! @details This is basically a copy of the juce::TooltipWindow class
//! that adds the possibility to set a custom tooltip client
//! that can be used to overwrite the original "mouse over component" behavior.
//! @see juce::TooltipWindow, CustomTooltipClient, juce::SettableTooltipClient
class TooltipWindow : public juce::Component, private juce::Timer
{
public: // methods
//! @brief Constructor.
//! @details Please see juce::TooltipWindow() for more details.
//! @see juce::TooltipWindow
explicit TooltipWindow(juce::Component* parentComponent = nullptr,
int m_milliseconds_before_tip_appears = 700);
//! @brief Destructor.
~TooltipWindow();
//! @brief Changes the time before the tip appears.
//! @details This lets you change the value that was set in the constructor.
void setMillisecondsBeforeTipAppears(int new_delay_ms = 700) noexcept;
//! @brief Can be called to manually force a tip to be shown at a particular location.
void displayTip(juce::Point<int> screen_position, juce::String const& text);
//! @brief Set a custom tooltip client.
//! @details When a CustomTooltipClient is set, the TooltipWindow will allways display it,
//! ignoring other Tooltip clients over the mouse, until it is manually unset or hidden.
//! @see CustomTooltipClient, unsetCustomTooltipClient
void setCustomTooltipClient(CustomTooltipClient& client);
//! @brief Unset a custom tooltip client.
//! @details If the client parameter is the one that is currently used, this will hide the tip.
//! @see CustomTooltipClient, setCustomTooltipClient
void unsetCustomTooltipClient(CustomTooltipClient& client);
//! @brief Can be called to manually hide the tip if it's showing.
void hideTip();
private: // methods
void paint(juce::Graphics&) override;
void mouseEnter(juce::MouseEvent const&) override;
void timerCallback() override;
void updatePosition(juce::String const&, juce::Point<int>, juce::Rectangle<int>);
private: // members
juce::Point<float> m_last_mouse_pos;
juce::Component* m_last_component_under_mouse = nullptr;
CustomTooltipClient* m_custom_client = nullptr;
CustomTooltipClient* m_last_custom_client = nullptr;
juce::String m_tip_showing, m_last_tip_under_mouse;
int m_milliseconds_before_tip_appears;
int m_mouse_clicks, m_mouse_wheel_moves;
unsigned int m_last_comp_change_time, m_last_hide_time;
bool m_reentrant;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(TooltipWindow)
};
}
| 5,565
|
C++
|
.h
| 90
| 49.4
| 104
| 0.542376
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,610
|
KiwiApp_ImageButton.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Components/KiwiApp_ImageButton.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
// ================================================================================ //
// IMAGE BUTTON //
// ================================================================================ //
//! @brief A button that displays a Drawable.
class ImageButton : public juce::Button
{
public: // methods
using ButtonStyle = juce::DrawableButton::ButtonStyle;
using ColourIds = juce::DrawableButton::ColourIds;
//! @brief Constructor.
ImageButton(juce::String const& button_name,
std::unique_ptr<juce::Drawable> drawable,
ButtonStyle style = ButtonStyle::ImageAboveTextLabel);
//! @brief Destructor.
~ImageButton();
//! @brief Sets up the images to draw for the various button states.
//! @see juce::DrawableButton::setImages()
void setImages(juce::Drawable const* normal_image,
juce::Drawable const* over_image = nullptr,
juce::Drawable const* down_image = nullptr,
juce::Drawable const* disabled_image = nullptr,
juce::Drawable const* normal_image_on = nullptr,
juce::Drawable const* over_image_on = nullptr,
juce::Drawable const* down_image_on = nullptr,
juce::Drawable const* disabled_image_on = nullptr);
//! @brief Set the command to execute when the button has been clicked.
void setCommand(std::function<void(void)> fn);
//! @brief Changes the button's style.
//! @see ButtonStyle
void setButtonStyle(ButtonStyle new_style);
//! @brief Returns the current style.
ButtonStyle getStyle() const noexcept;
//! @brief Gives the button an optional amount of space around the edge of the drawable.
//! @details By default there's a gap of about 3 pixels.
void setEdgeIndent(int num_pixels_indent);
//! @brief Returns the image that the button is currently displaying.
juce::Drawable* getCurrentImage() const noexcept;
//! @brief Returns the image that the button will use for its normal state.
juce::Drawable* getNormalImage() const noexcept;
//! @brief Returns the image that the button will use when the mouse is over it.
juce::Drawable* getOverImage() const noexcept;
//! @brief Returns the image that the button will use when the mouse is held down on it.
juce::Drawable* getDownImage() const noexcept;
//! @brief Can be overridden to specify a custom position for the image within the button.
virtual juce::Rectangle<float> getImageBounds() const;
protected: // methods
//! @internal
void paintButton(juce::Graphics&, bool isMouseOverButton, bool isButtonDown) override;
//! @internal
void buttonStateChanged() override;
//! @internal
void resized() override;
//! @internal
void enablementChanged() override;
//! @internal
void colourChanged() override;
//! @brief This method is called when the button has been clicked.
void clicked(juce::ModifierKeys const& modifiers) override;
private: // members
ButtonStyle m_style;
std::unique_ptr<juce::Drawable> m_normal_image, m_over_image, m_down_image, m_disabled_image,
m_normal_image_on, m_over_image_on, m_down_image_on, m_disabled_image_on;
juce::Drawable* m_current_image;
int m_edge_indent;
std::function<void(void)> m_command = nullptr;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ImageButton)
};
}
| 5,060
|
C++
|
.h
| 86
| 46.255814
| 102
| 0.574862
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,611
|
KiwiApp_BinaryData.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Resources/KiwiApp_BinaryData.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
// ============================================================================
// This is an auto-generated file: Any edits you make may be overwritten!
// ============================================================================
#pragma once
namespace kiwi
{
namespace binary_data
{
namespace settings
{
extern char const* network_settings;
const int network_settings_size = 177;
}
namespace images
{
extern char const* plus_png;
const int plus_png_size = 6336;
extern char const* kiwi_icon_png;
const int kiwi_icon_png_size = 24099;
extern char const* kiwi_filetype_png;
const int kiwi_filetype_png_size = 40975;
extern char const* arrow_up_png;
const int arrow_up_png_size = 1635;
extern char const* dsp_off_png;
const int dsp_off_png_size = 12813;
extern char const* infinite_loop_png;
const int infinite_loop_png_size = 16276;
extern char const* zoom_in_png;
const int zoom_in_png_size = 14970;
extern char const* search_png;
const int search_png_size = 15008;
extern char const* users_png;
const int users_png_size = 8538;
extern char const* folder_png;
const int folder_png_size = 2557;
extern char const* minus_png;
const int minus_png_size = 5162;
extern char const* locked_png;
const int locked_png_size = 6215;
extern char const* zoom_out_png;
const int zoom_out_png_size = 14388;
extern char const* dsp_on_png;
const int dsp_on_png_size = 16455;
extern char const* open_png;
const int open_png_size = 1100;
extern char const* trash_png;
const int trash_png_size = 6810;
extern char const* unlocked_png;
const int unlocked_png_size = 6499;
extern char const* arrow_down_png;
const int arrow_down_png_size = 1647;
extern char const* refresh_png;
const int refresh_png_size = 15500;
}
namespace fonts
{
namespace open_sans
{
extern char const* OpenSans_Semibold_ttf;
const int OpenSans_Semibold_ttf_size = 221328;
extern char const* OpenSans_Light_ttf;
const int OpenSans_Light_ttf_size = 222412;
extern char const* OpenSans_Italic_ttf;
const int OpenSans_Italic_ttf_size = 212896;
extern char const* OpenSans_ExtraBold_ttf;
const int OpenSans_ExtraBold_ttf_size = 222584;
extern char const* OpenSans_LightItalic_ttf;
const int OpenSans_LightItalic_ttf_size = 213128;
extern char const* OpenSans_Bold_ttf;
const int OpenSans_Bold_ttf_size = 224592;
extern char const* OpenSans_SemiboldItalic_ttf;
const int OpenSans_SemiboldItalic_ttf_size = 212820;
extern char const* OpenSans_ExtraBoldItalic_ttf;
const int OpenSans_ExtraBoldItalic_ttf_size = 213420;
extern char const* OpenSans_Regular_ttf;
const int OpenSans_Regular_ttf_size = 217360;
extern char const* OpenSans_BoldItalic_ttf;
const int OpenSans_BoldItalic_ttf_size = 213292;
}
}
}
}
| 4,462
|
C++
|
.h
| 96
| 35.354167
| 90
| 0.550728
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,612
|
KiwiApp_PatcherViewIoletHighlighter.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewIoletHighlighter.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
#include "../KiwiApp_Components/KiwiApp_TooltipWindow.h"
namespace kiwi
{
class ObjectFrame;
// ================================================================================ //
// IOLET HILIGHTER //
// ================================================================================ //
class IoletHighlighter
: public juce::Component
, public CustomTooltipClient
{
public:
//! @brief Constructor.
IoletHighlighter();
//! @brief Destructor.
~IoletHighlighter() = default;
//! @brief The paint method.
void paint(juce::Graphics& g) override;
//! @brief Stop highlighting.
void hide();
//! @brief Highlight inlet
void highlightInlet(ObjectFrame const& object, const size_t index);
//! @brief Highlight outlet
void highlightOutlet(ObjectFrame const& object, const size_t index);
//! @brief Returns the string that this object wants to show as its tooltip.
juce::String getTooltip() override;
//! @brief Returns the bounds of the tooltip to show.
juce::Rectangle<int> getTooltipBounds(juce::String const& tip,
juce::Point<int>,
juce::Rectangle<int> parent_area,
int width,
int height) override;
//! @brief Overriden to provide a custom drawing method.
bool drawTooltip(juce::Graphics& g,
juce::String const& text,
int width, int height) override;
private: // methods
void highlight(ObjectFrame const& object, const size_t index, bool is_inlet);
private: // members
bool m_is_inlet;
std::string m_text;
std::string m_object_name;
bool m_show_tooltip_on_left;
size_t m_last_index;
flip::Ref m_object_ref;
};
}
| 3,279
|
C++
|
.h
| 63
| 39.571429
| 91
| 0.494098
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,613
|
KiwiApp_PatcherViewMouseHandler.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewMouseHandler.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <map>
#include <memory>
#include <juce_gui_basics/juce_gui_basics.h>
#include <flip/Ref.h>
#include <KiwiModel/KiwiModel_Object.h>
namespace kiwi
{
class PatcherView;
class ObjectFrame;
class HitTester;
// ================================================================================ //
// MOUSEHANDLER //
// ================================================================================ //
//! @brief The mouse handler is used to make the patcher view react to the mouse interactions.
class MouseHandler
{
public: // enums
enum class Action
{
None = 0,
CopyOnDrag,
ForwardToObject,
CreateLink,
Lasso,
MoveObjects,
ResizeObjects,
EditObject,
SwitchSelection,
Selection,
SwitchLock,
PopupMenu,
OpenObjectHelp,
};
enum Direction : int
{
None = 0,
Up = 1 << 0,
Down = 1 << 1,
Left = 1 << 2,
Right = 1 << 3
};
public: // methods
//! @brief Returns the current action.
Action getCurrentAction();
//! @brief Constructor.
MouseHandler(PatcherView & patcher_view);
//! @brief Destructor.
~MouseHandler();
//! @brief Handles patcher view's mouse down event.
void handleMouseDown(juce::MouseEvent const& e);
//! @brief Handles patcher view's mouse drag event.
void handleMouseDrag(juce::MouseEvent const& e);
//! @brief Handles patcher view's mouse up event.
void handleMouseUp(juce::MouseEvent const& e);
//! @brief Handles patcher view's mouse double click events.
void handleMouseDoubleClick(juce::MouseEvent const& e);
//! @brief Handles patcher view's mouse move events.
void handleMouseMove(juce::MouseEvent const& e);
private: // methods
//! @brief Starts an interaction with the patcher view.
void startAction(Action action, juce::MouseEvent const& e);
//! @brief Continues an initiated interaction with the patcher view.
void continueAction(juce::MouseEvent const& e);
//! @brief Ends an ongoing interaction with patch.
void endAction(juce::MouseEvent const& e);
//! @brief Returns the resize direction according to the hit_tester.
int getResizeDirection(HitTester const& hit_tester) const;
//! @brief Returns the right resize mouse cursor.
juce::MouseCursor::StandardCursorType getMouseCursorForBorder(HitTester const& hit_tester) const;
//! @brief Resize the model object's bounds
void resizeModelObjectBounds(model::Object& model,
ObjectFrame& box,
juce::Rectangle<int> prev_bounds,
juce::Point<int> delta, bool fixed_ratio);
private: // members
PatcherView& m_patcher_view;
Action m_current_action = Action::None;
juce::Point<int> m_last_drag {};
std::map<flip::Ref, juce::Rectangle<int>> m_mousedown_bounds {};
int m_direction = 0;
private: // deleted methods
MouseHandler() = delete;
MouseHandler(MouseHandler const& other) = delete;
MouseHandler(MouseHandler && other) = delete;
MouseHandler& operator=(MouseHandler const& other) = delete;
MouseHandler& operator=(MouseHandler && other) = delete;
};
}
| 4,873
|
C++
|
.h
| 103
| 36.786408
| 105
| 0.544153
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,614
|
KiwiApp_Factory.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Factory.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#include <functional>
#include <memory>
#include <map>
#include <KiwiModel/KiwiModel_Object.h>
#include <KiwiModel/KiwiModel_Factory.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
#pragma once
namespace kiwi
{
// ================================================================================ //
// FACTORY //
// ================================================================================ //
class Factory
{
public: // definitions
using ctor_fn_t = std::function<std::unique_ptr<ObjectView>(model::Object & model)>;
public: // methods
//! @brief The construction methods.
//! @details Returns an object corresponding to a certain object's model.
static std::unique_ptr<ObjectView> createObjectView(model::Object & object_model);
//! @brief Adds a object to the factory.
template<class TObject>
static void add(std::string const& name, ctor_fn_t create_method)
{
static_assert(std::is_base_of<ObjectView, TObject>::value,
"object's view doesn't inherit from class ObjectView");
static_assert(!std::is_abstract<TObject>::value,
"The object's view must not be abstract.");
assert(model::Factory::has(name) && "Adding an engine object that has no corresponding model");
assert(m_creators.count(name) == 0 && "The object already exists");
m_creators[name] = create_method;
};
static std::map<std::string, ctor_fn_t> m_creators;
private: // deleted methods
Factory() = delete;
~Factory() = delete;
Factory(Factory const& other) = delete;
Factory(Factory && other) = delete;
Factory& operator=(Factory const& other) = delete;
Factory& operator=(Factory && other) = delete;
};
}
| 2,979
|
C++
|
.h
| 56
| 43.75
| 108
| 0.542039
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,615
|
KiwiApp_PatcherManager.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherManager.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <unordered_set>
#include <memory>
#include <juce_gui_extra/juce_gui_extra.h>
#include <flip/Document.h>
#include <flip/DocumentObserver.h>
#include <KiwiModel/KiwiModel_PatcherUser.h>
#include <KiwiModel/KiwiModel_PatcherValidator.h>
#include <KiwiApp_Network/KiwiApp_DocumentBrowser.h>
#include <KiwiApp_Network/KiwiApp_CarrierSocket.h>
namespace kiwi
{
class Instance;
class PatcherView;
class PatcherViewWindow;
// ================================================================================ //
// PATCHER MANAGER //
// ================================================================================ //
//! @brief The main DocumentObserver.
//! @details The Instance dispatch changes to all other DocumentObserver objects
class PatcherManager
: public flip::DocumentObserver<model::Patcher>
, public DocumentBrowser::Drive::Listener
{
public: // nested classes
struct Listener;
public: // methods
//! @brief Constructor.
PatcherManager(Instance& instance, std::string const& name);
//! @brief Destructor.
~PatcherManager();
//! @brief Try to create a patcher manager from a file
//! @details This method throws a std::runtime exception if error occurs during read.
//! @return A PatcherManager if succeed, nullptr otherwise.
static std::unique_ptr<PatcherManager> createFromFile(Instance& instance,
juce::File const& file);
//! @brief Try to connect this patcher to a remote server.
bool connect(std::string const& host, uint16_t port, DocumentBrowser::Drive::DocumentSession& session);
//! @brief Disconnects the patcher manager.
void disconnect();
//! @brief Pull changes from server if it is remote.
void pull();
//! @brief Save the document.
//! @details Returns true if saving document succeeded false otherwise.
bool saveDocument(bool save_as);
//! @brief Save the document as another document.
//! @details Returns true if saving document succeeded false otherwise.
bool saveDocumentAs();
//! @brief Returns true if the patcher needs to be saved.
bool needsSaving() const noexcept;
//! @brief Returns the file currently used to save document.
juce::File const& getSelectedFile() const;
//! @brief Returns the Patcher model
model::Patcher& getPatcher();
//! @brief Returns the Patcher model
model::Patcher const& getPatcher() const;
//! @brief Returns true if the this is a remotely connected document.
bool isConnected() const noexcept;
//! @brief Returns the session ID of the document.
//! @details This function returns 0 if the document is loaded from disk or memory.
//! @see isConnected
uint64_t getSessionId() const noexcept;
//! @brief Returns the name of the document.
//! @details This function returns 0 if the document is loaded from disk or memory.
//! @see isConnected
std::string getDocumentName() const;
//! @brief Returns the number of users connected to the patcher document.
size_t getNumberOfUsers();
//! @brief Returns the list of users connected to the patcher document.
std::unordered_set<uint64_t> getConnectedUsers();
//! @brief Returns the number of patcher views.
size_t getNumberOfView();
//! @brief create a new patcher view window.
void newView();
//! @brief Brings the first patcher view to front.
void bringsFirstViewToFront();
//! @brief Attempt to close all document windows, after asking user to save them if needed.
//! @return True if all document have been closed, false if the user cancel the action.
bool askAllWindowsToClose();
//! @brief Returns the first window of the patcher manager.
PatcherViewWindow & getFirstWindow();
//! @brief Close the window that contains a given patcherview.
//! @details if it's the last patcher view, it will ask the user the save the document before closing if needed.
void closePatcherViewWindow(PatcherView& patcherview);
//! @brief Add a listener.
void addListener(Listener& listener);
//! @brief remove a listener.
void removeListener(Listener& listener);
//! @brief Force all windows to close without asking user to save document.
void forceCloseAllWindows();
//! @brief This method is used to reset the stack count when a stack-overflow has previously been detected.
//! @details it will signal the Patcher model
void clearStackOverflow();
bool hasStackOverflow() const;
private:
//! @brief Called when a document session has been added.
void documentAdded(DocumentBrowser::Drive::DocumentSession& doc) override;
//! @brief Called when a document session changed.
void documentChanged(DocumentBrowser::Drive::DocumentSession& doc) override;
//! @brief Called when the drive connection status changed.
void driveConnectionStatusChanged(bool is_online) override;
//! @internal Called from socket process to notify changing state.
void onStateTransition(flip::CarrierBase::Transition transition, flip::CarrierBase::Error error);
//! @brief Called when a stack-overflow is detected
void onStackOverflowDetected(std::vector<flip::Ref> refs);
//! @brief Called when a stack-overflow is cleared
void onStackOverflowCleared();
//! @internal Write data into file.
void writeDocument();
//! @internal Reads from binary data file.
bool readBackEndBinary(flip::DataProviderBase& data_provider);
//! @brief Load patcher datas from file.
//! @details Loading document from file could fail if the file can not be read.
//! This could happen if the file has not a valid extension,
//! or if the document version is incompatible.
//! @exception Throws a std::runtime exception if file loading fail.
bool loadFromFile(juce::File const& file);
//! @internal flip::DocumentObserver<model::Patcher>::document_changed
void document_changed(model::Patcher& patcher) override final;
//! @internal Notify and create PatcherViews.
void notifyPatcherViews(model::Patcher& patcher);
//! @internal React to the fact that a View has just been added to the document.
//! @details create a PatcherViewWindow.
void createPatcherWindow(model::Patcher& patcher,
model::Patcher::User const& user,
model::Patcher::View& view);
//! @internal View is resident and internal value changed.
void notifyPatcherView(model::Patcher& patcher,
model::Patcher::User const& user,
model::Patcher::View& view);
//! @internal Vser will be removed from the document.
void removePatcherWindow(model::Patcher& patcher,
model::Patcher::User const& user,
model::Patcher::View& view);
//! @internal Save document if needed and if user agrees.
//! returns true if user wants to continue editing.
bool saveIfNeededAndUserAgrees();
//! @internal Updates the title bar of specific view.
void updateTitleBar(model::Patcher::View & view);
//! @internal Updates windows title bars according to remote state,
//! need saving flag, name and selected file.
void updateTitleBars();
//! @internal Sets the need saving flags. Updates title bar if requested.
void setNeedSaving(bool need_saving);
//! @internal Sets the patcher manager's name. Updates title bar if requested.
void setName(std::string const& name);
private: // members
std::string m_name;
Instance& m_instance;
model::PatcherValidator m_validator;
flip::Document m_document;
juce::File m_file;
CarrierSocket m_socket;
bool m_need_saving_flag = false;
DocumentBrowser::Drive::DocumentSession* m_session = nullptr;
flip::SignalConnection m_user_connected_signal_cnx;
flip::SignalConnection m_user_disconnected_signal_cnx;
flip::SignalConnection m_receive_connected_users_signal_cnx;
flip::SignalConnection m_stack_overflow_detected_signal_cnx;
flip::SignalConnection m_stack_overflow_cleared_signal_cnx;
std::unordered_set<uint64_t> m_connected_users;
bool m_has_stack_overflow = false;
tool::Listeners<Listener> m_listeners;
};
// ================================================================================ //
// PATCHER MANAGER LISTENER //
// ================================================================================ //
struct PatcherManager::Listener
{
virtual ~Listener() {};
//! @brief Called when one or more users are connecting or disconnecting to the Patcher Document.
virtual void connectedUserChanged(PatcherManager& manager) {};
//! @brief Called when a stack-overflow is detected.
virtual void stackOverflowDetected(PatcherManager& manager, std::vector<flip::Ref> culprits) {};
//! @brief Called when a stack-overflow is cleared.
virtual void stackOverflowCleared(PatcherManager& manager) {};
};
}
| 11,854
|
C++
|
.h
| 192
| 48.927083
| 121
| 0.593634
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,616
|
KiwiApp_PatcherComponent.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherComponent.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include "../KiwiApp_Components/KiwiApp_Window.h"
#include "KiwiApp_PatcherManager.h"
namespace kiwi
{
// ================================================================================ //
// PATCHER COMPONENT TOOLBAR //
// ================================================================================ //
class PatcherToolbar
: public juce::Component
{
public: // methods
//! @brief Constructor.
PatcherToolbar(PatcherManager& patcher_manager);
//! @brief Destructor.
~PatcherToolbar();
//! @brief juce::Component::resized
void resized() override;
//! @brief Removes users icon.
void removeUsersIcon();
//! @brief Show or hide stack-overflow icon.
void setStackOverflowIconVisible(bool visible);
private: // classes
//! called by custom toolbar lookandfeel.
void paintToolbarBackground(juce::Graphics& g, int width, int height);
//! @internal Toolbar item factory
struct Factory : public juce::ToolbarItemFactory
{
Factory(PatcherManager& patcher_manager);
enum ItemIds
{
lock_unlock = 1,
zoom_in = 2,
zoom_out = 3,
dsp_on_off = 4,
users = 5,
stack_overflow = 6,
};
void getAllToolbarItemIds(juce::Array<int>& ids) override;
void getDefaultItemSet(juce::Array<int>& ids) override;
juce::ToolbarItemComponent* createItem(int itemId) override;
PatcherManager& m_patcher_manager;
};
class UsersItemComponent;
//! @brief Returns the index of a specific item id in the toolbar.
//! @details returns -1 if the item is not found.
int getToolbarItemIndex(Factory::ItemIds item_id);
private: // variables
PatcherManager& m_patcher_manager;
juce::Toolbar m_toolbar;
Factory m_factory;
std::unique_ptr<juce::LookAndFeel> m_toolbar_look_and_feel = nullptr;
class PatcherToolbarLookAndFeel;
};
// ================================================================================ //
// TOOLBAR USER COMPONENT //
// ================================================================================ //
//! @brief A toolbar component that displays informations about the users of the patch
class PatcherToolbar::UsersItemComponent
: public juce::ToolbarItemComponent
, public PatcherManager::Listener
, private juce::Timer
{
public: // methods
//! @brief Constructor.
UsersItemComponent(const int toolbarItemId, PatcherManager& patcher_manager);
//! @brief Destructor.
~UsersItemComponent();
//! @brief Called when one or more users are connecting or disconnecting to the Patcher Document.
void connectedUserChanged(PatcherManager& manager) override;
//! @brief Call to update the number of users displayed and user names.
void updateUsers();
//! @brief Provides prefered size for this item.
bool getToolbarItemSizes(int toolbarDepth, bool isVertical,
int& preferredSize, int& minSize, int& maxSize) override;
//! @brief Paint the button area.
void paintButtonArea(juce::Graphics&, int width, int height,
bool isMouseOver, bool isMouseDown) override;
//! @brief Called when content area changed.
void contentAreaChanged(const juce::Rectangle<int>& newArea) override;
//! @brief Starts this component flashing.
void startFlashing();
//! @brief Stops this component flashing.
void stopFlashing();
//! @brief Displays the list of usernames.
void mouseDown(juce::MouseEvent const& e) override final;
private: // methods
//! @internal juce::Timer callback.
void timerCallback() override;
private: // variables
PatcherManager& m_patcher_manager;
std::vector<std::string> m_users;
size_t m_user_nb;
const juce::Image m_users_img;
float m_flash_alpha = 0.f;
};
// ================================================================================ //
// PATCHER COMPONENT //
// ================================================================================ //
//! @brief The PatcherComponent holds a patcher view and a patcher toolbar.
class PatcherComponent
: public juce::Component
, private PatcherManager::Listener
, public juce::ApplicationCommandTarget
{
public: // methods
//! @brief Constructor
PatcherComponent(PatcherView& patcherview);
//! @brief Destructor
~PatcherComponent();
//! @brief juce::Component::resized
void resized() override;
//! @brief Returns the patcher view.
PatcherView& usePatcherView();
//! @brief Returns the patcher manager.
PatcherManager& usePatcherManager();
//! @brief juce::Component::paint
void paint(juce::Graphics& g) override;
//! @brief Removes the users icon from toolbar;
void removeUsersIcon();
// -------------------------------------------------------------------------------- //
// APPLICATION COMMAND TARGET //
// -------------------------------------------------------------------------------- //
juce::ApplicationCommandTarget* getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
void getCommandInfo(juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform(const InvocationInfo& info) override;
private: // methods
//! @brief Called when a stack-overflow is detected;
void stackOverflowDetected(PatcherManager& manager, std::vector<flip::Ref> culprits) override;
//! @brief Called when a stack-overflow is cleared.
void stackOverflowCleared(PatcherManager& manager) override;
private: // members
PatcherManager& m_patcher_manager;
PatcherView& m_patcherview;
PatcherToolbar m_toolbar;
};
// ================================================================================ //
// PATCHER VIEW WINDOW //
// ================================================================================ //
class PatcherViewWindow
: public Window
, public juce::ComponentMovementWatcher
{
public: // methods
PatcherViewWindow(PatcherManager& manager, PatcherView& patcherview);
//! @brief Shows an modal window asking for user input.
bool showOkCancelBox(juce::AlertWindow::AlertIconType icon_type,
std::string const& title,
std::string const& message,
std::string const& button_1,
std::string const& button_2);
void closeButtonPressed() override;
//! @brief returns the patcher manager.
PatcherManager& getPatcherManager();
//! @brief returns the PatcherView.
PatcherView& getPatcherView();
//! @brief Removes the connected users icon. Called once patcher disconnected.
void removeUsersIcon();
private: // methods
void componentMovedOrResized(bool was_moved, bool was_resized) override;
void componentPeerChanged() override {};
void componentVisibilityChanged() override {}
private: // variables
PatcherComponent m_patcher_component;
};
}
| 9,765
|
C++
|
.h
| 181
| 41.060773
| 106
| 0.526298
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,617
|
KiwiApp_PatcherViewHitTester.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewHitTester.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
class PatcherView;
class ObjectFrame;
class LinkView;
// ================================================================================ //
// HITTESTER //
// ================================================================================ //
//! @brief The HitTester class...
class HitTester
{
public:
//! @brief The target type
enum class Target : int
{
Nothing = 0,
Patcher = 1,
Box = 2,
Link = 3
};
//! @brief The Zone
enum class Zone : int
{
Outside = 1<<0,
Inside = 1<<1,
Inlet = 1<<2,
Outlet = 1<<3,
Border = 1<<4
};
//! @brief The Border type
enum Border
{
None = 1<<0,
Left = 1<<1,
Right = 1<<2,
Top = 1<<3,
Bottom = 1<<4,
};
//! @brief Contructor.
HitTester(PatcherView const& patcher);
//! @brief Destructor.
~HitTester();
//! @brief Reset the hit test.
//! @brief @details Resets the hit test as it has never touched any box, link or patcher zone.
void reset();
//! @brief Run a hit test on object and links for a given point.
//! @details The function try to find an object or a link under the point,
//! otherwise it will consider that the patcher has been touched.
//! @param point The point to test.
void test(juce::Point<int> const& point) noexcept;
//! @brief Test a point.
//! @details Try to find an object box under the point.
//! @param point The point to test.
//! @return true if the point hit an object box.
bool testObjects(juce::Point<int> const& point) noexcept;
//! @brief Test a point.
//! @details Try to find a link.
//! @param point The point to test.
//! @return true if the point hit a link.
bool testLinks(juce::Point<int> const& point) noexcept;
//! @brief Test a rectangle.
//! @details Try to find the objects and links that overlaps the rectangle.
//! @param rect The rectangle to test.
//! @param objects The vector of objects that will be filled.
//! @param links The vector of links that will be filled.
void test(juce::Rectangle<int> const& rect,
std::vector<ObjectFrame*>& objects,
std::vector<LinkView*>& links);
//! @brief Test a rectangle.
//! @details Try to find the objects that overlaps the given rectangle.
//! @param rect The rectangle.
//! @param objects The vector of objects that will be filled.
void testObjects(juce::Rectangle<int> const& rect, std::vector<ObjectFrame*>& objects);
//! @brief Test a rectangle.
//! @details Try to find the links that overlaps the given rectangle.
//! @param rect The rectangle.
//! @param links The vector of links that will be filled.
void testLinks(juce::Rectangle<int> const& rect, std::vector<LinkView*>& links);
//! @brief Get the last touched Target.
inline Target getTarget() const noexcept { return m_target; }
//! @brief Returns true if nothing has been hit by the test, otherwise returns false.
inline bool nothingTouched() const noexcept { return m_target == Target::Nothing; }
//! @brief Returns true if the test hit the patcher, otherwise return false.
inline bool patcherTouched() const noexcept { return m_target == Target::Patcher; }
//! @brief Returns true if the test hit an object, otherwise return false.
inline bool objectTouched() const noexcept { return m_target == Target::Box; }
//! @brief Returns true if the test hit a link, otherwise return false.
inline bool linkTouched() const noexcept { return m_target == Target::Link; }
//! @brief Get the patcher.
PatcherView const& getPatcher() const noexcept;
//! @brief Get the object box that has been touched by the last hit-test.
ObjectFrame* getObject() const noexcept;
//! @brief Get the link that has been touched by the last hit-test.
LinkView* getLink() const noexcept;
//! @brief Get the Zone of the Target that result of the hit-test.
//! @details Get the Zone of the Target that result of the hit-test.
//! If a patcher has hit, it can be inside or outside.
//! If an object box has hit, it can be one of all the zones.
//! If a link has hit, it can only be the four first zones.
//! It nothing hit, it will be outside.
//! @return The Zone of the Target that result of the hit-test.
Zone getZone() const noexcept;
//! @brief Returns the type of border (if a border of an object box has hit).
int getBorder() const noexcept;
//! @brief Returns the index of the Zone of the object box.
//! @details Get the index of the Zone of the object box.
//! If the object Zone is an inlet or an outlet, it will be their index.
//! If the object Zone is a border or a corner it will be their position.
//! @return The index of the zone of the object box.
size_t getIndex() const noexcept;
private: // members
PatcherView const& m_patcher;
ObjectFrame* m_object = nullptr;
LinkView* m_link = nullptr;
Target m_target = Target::Nothing;
Zone m_zone = Zone::Outside;
int m_border = Border::None;
size_t m_index = 0;
friend class LinkView;
friend class ObjectFrame;
};
}
| 7,166
|
C++
|
.h
| 138
| 41.586957
| 103
| 0.558663
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,618
|
KiwiApp_PatcherViewLasso.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewLasso.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include "flip/Ref.h"
#include <juce_gui_extra/juce_gui_extra.h>
#include <set>
#include "../KiwiApp_Components/KiwiApp_TooltipWindow.h"
namespace kiwi
{
class PatcherView;
class ObjectFrame;
// ================================================================================ //
// LASSO //
// ================================================================================ //
class Lasso : public juce::Component
{
public:
//! @brief Contructor.
Lasso(PatcherView& patcher);
//! @grief Destructor.
~Lasso();
//! @brief The paint method.
void paint(juce::Graphics& g) override;
//! @brief Begins the selection of the links and the boxes.
//! @param point The starting point.
//! @param preserve_selection The lasso should preserve the current selection.
void begin(juce::Point<int> const& point, const bool preserve_selection);
//! @brief Perform the selection of the links and the boxes.
//! @param point The draging point.
//! @param objects The lasso should add objects to the selection.
//! @param links The lasso should add links to the selection.
//! @param preserve The lasso should preserve the last selection.
void perform(juce::Point<int> const& point, bool objects, bool links, const bool preserve);
//! @brief Ends the selection of the links and the boxes.
void end();
//! Retrieve Returns true if the Lasso is performing the selection.
bool isPerforming() const noexcept;
private: // members
PatcherView& m_patcher;
std::set<flip::Ref> m_objects;
std::set<flip::Ref> m_links;
juce::Point<int> m_start;
bool m_dragging;
};
}
| 2,901
|
C++
|
.h
| 57
| 41.929825
| 100
| 0.548889
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,619
|
KiwiApp_PatcherViewport.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherViewport.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_extra/juce_gui_extra.h>
namespace kiwi
{
class PatcherView;
class ObjectFrame;
// ================================================================================ //
// PATCHER VIEWPORT //
// ================================================================================ //
//! @brief The PatcherView Viewport
class PatcherViewport : public juce::Viewport
{
public:
//! @brief Constructor
PatcherViewport(PatcherView& patcher);
//! @brief Destructor
~PatcherViewport() = default;
//! @brief Called by juce::Viewport when the visible area changed
void visibleAreaChanged(juce::Rectangle<int> const& new_visible_area) override;
//! @brief Overriden from juce::Viewport to update patcher area on viewport resize.
void resized() override;
//! @brief Make the object visible in the viewport area.
void jumpViewToObject(ObjectFrame const&);
//! @brief Attempts to brings the center of the given bounds to the center of the viewport view area
void bringRectToCentre(juce::Rectangle<int> bounds);
//! @brief Transforms a given point into a point relative to the patcher origin position.
juce::Point<int> getRelativePosition(juce::Point<int> point) const noexcept;
//! @brief Returns the current patcher area relative to the patcher origin position.
juce::Rectangle<int> getRelativeViewArea() const noexcept;
//! @brief Get the view position relative to the patcher origin position.
juce::Point<int> getRelativeViewPosition() const noexcept;
//! @brief Set the new view position relative to the patcher origin position.
void setRelativeViewPosition(juce::Point<int> position);
//! @brief Set the zoom factor.
//! @details The non-zooming factor is 1., 2. means zoom at 200%, -0.5 zoom at 50% and so on.
void setZoomFactor(double zoom_factor);
//! @brief Returns the current zoom factor.
double getZoomFactor() const noexcept;
//! @brief Returns the position of the patcher origin relative to the component position.
juce::Point<int> getOriginPosition() const noexcept;
//! @brief Reset the objects area.
void resetObjectsArea();
//! @brief Returns the current objects area.
juce::Rectangle<int> getObjectsArea() const noexcept;
//! @brief Update patcher size.
void updatePatcherArea(bool keep_same_view_position);
private: // members
//! @internal Hook method called by PatcherViewport just before resized.
void viewportResized(juce::Rectangle<int> const& last_bounds,
juce::Rectangle<int> const& new_bounds);
private: // members
PatcherView& m_patcher;
Component m_magnifier;
juce::Rectangle<int> m_last_bounds {};
juce::Rectangle<int> m_patching_area {};
double m_zoom_factor = 1.;
bool m_can_hook_resized = false;
};
}
| 4,365
|
C++
|
.h
| 73
| 48.835616
| 109
| 0.582347
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,620
|
KiwiApp_LinkView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_LinkView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiModel/KiwiModel_Link.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectFrame.h>
namespace kiwi
{
class PatcherView;
class LinkView;
// ================================================================================ //
// LINK VIEW BASE //
// ================================================================================ //
//! @brief The LinkView base class.
class LinkViewBase : public juce::Component
{
public:
LinkViewBase() = default;
virtual ~LinkViewBase() = default;
protected:
void updateBounds();
protected: // members
juce::Point<int> m_last_outlet_pos;
juce::Point<int> m_last_inlet_pos;
juce::Path m_path;
};
// ================================================================================ //
// LINK VIEW //
// ================================================================================ //
//! @brief The juce link Component.
class LinkView : public LinkViewBase, public juce::ComponentListener
{
public:
//! @brief Constructor
LinkView(PatcherView& patcherview, model::Link& link_m);
//! @brief Destructor
~LinkView();
//! @brief LinkView colors
enum ColourIds
{
ControlBackground = 0x2110010,
SignalBackground = 0x2110012,
};
//! @brief Get the Link model
model::Link& getModel() const;
//! Returns true if the link is selected.
bool isSelected() const noexcept;
void linkChanged(model::Link& link);
void objectChanged(model::Object& object);
void localSelectionChanged(bool selected_for_view);
void distantSelectionChanged(std::set<uint64_t> distant_user_id_selection);
// ! @brief Returns true if this link reprensent a signal connection.
bool isSignal() const;
// juce::Component
void paint(juce::Graphics& g) override;
using juce::Component::hitTest; // silent virtual function overload hiding warning
//! @brief internal kiwi PatcherView Hit-Testing.
bool hitTest(juce::Point<int> const& pt, HitTester& result) const;
//! @brief internal kiwi PatcherView HitTesting (overlaps a rectangle).
bool hitTest(juce::Rectangle<float> const& rect);
//! @brief Called when the component's position or size changes.
//! @param component the component that was moved or resized
//! @param wasMoved true if the component's top-left corner has just moved
//! @param wasResized true if the component's width or height has just changed
void componentMovedOrResized(Component& component,
bool was_moved, bool was_resized) override;
private: // members
struct Selection
{
bool on_this_view = false;
bool in_another_view = false;
bool by_another_user = false;
operator bool () const
{
return (on_this_view || in_another_view || by_another_user);
}
};
PatcherView& m_patcherview;
model::Link* m_model {nullptr};
Selection m_selected {};
};
// ================================================================================ //
// LINK VIEW CREATOR //
// ================================================================================ //
//! @brief The LinkView creator helper.
class LinkViewCreator : public LinkViewBase
{
public:
//! @brief Constructor
LinkViewCreator(ObjectFrame& binded_object,
const size_t index,
bool is_sender,
juce::Point<int> dragged_pos);
//! @brief Destructor
~LinkViewCreator() = default;
//! @brief Get the binded object
ObjectFrame& getBindedObject() const {return m_binded_object;};
//! @brief Get the portlet index
size_t getBindedIndex() const {return m_index;};
//! @brief Returns true if the link is binded to an outlet.
size_t isBindedToSender() const {return m_is_sender;};
//! @brief Set end position of the link
void setEndPosition(juce::Point<int> const& pos);
//! @brief Get The end position of the link
juce::Point<int> getEndPosition() const noexcept;
// juce::Component
void paint(juce::Graphics& g) override;
private: // members
ObjectFrame& m_binded_object;
const size_t m_index;
const bool m_is_sender;
};
}
| 6,231
|
C++
|
.h
| 124
| 38.677419
| 91
| 0.50843
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,621
|
KiwiApp_PatcherView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_PatcherView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiModel/KiwiModel_Patcher.h>
#include <KiwiApp_Patcher/KiwiApp_PatcherViewMouseHandler.h>
#include "KiwiApp_PatcherViewport.h"
#include "KiwiApp_PatcherViewHitTester.h"
#include "KiwiApp_PatcherManager.h"
#include "KiwiApp_PatcherViewLasso.h"
#include "KiwiApp_PatcherViewIoletHighlighter.h"
namespace kiwi
{
class PatcherManager;
class ObjectFrame;
class LinkView;
class LinkViewCreator;
class Instance;
// ================================================================================ //
// PATCHER VIEW //
// ================================================================================ //
//! @brief The juce Patcher Component.
class PatcherView
: public juce::Component
, public juce::ApplicationCommandTarget
, public PatcherManager::Listener
{
public:
//! @brief Constructor
PatcherView(PatcherManager& manager,
Instance& instance,
model::Patcher& patcher,
model::Patcher::View& view);
//! @brief Destructor
~PatcherView();
//! @brief PatcherView colors
enum ColourIds
{
BackgroundUnlocked = 0x2100010,
BackgroundLocked = 0x2100012,
Selection = 0x2100100,
SelectionOtherView = 0x2100105,
SelectionOtherUser = 0x2100110
};
using ObjectFrames = std::vector<std::unique_ptr<ObjectFrame>>;
using LinkViews = std::vector<std::unique_ptr<LinkView>>;
//! @brief Returns the PatcherManager.
PatcherManager& usePatcherManager();
//! @internal flip::DocumentObserver<model::Patcher>::document_changed
void patcherChanged(model::Patcher& patcher, model::Patcher::View& view);
//! @brief Returns the patcher view model.
model::Patcher::View& getPatcherViewModel();
//! @brief Returns the Objects' frames.
ObjectFrames const& getObjects() const;
//! @brief Returns the LinkViews.
LinkViews const& getLinks() const;
//! @brief Returns the Object's frame corresponding to a given Object model.
ObjectFrame* getObject(model::Object const& object);
//! @brief Returns the LinkView corresponding to a given Link model.
LinkView* getLink(model::Link const& link);
//! @brief Called by the patcherWindow when loaded
void windowInitialized();
//! @brief Save the state of the patcherview in the model.
void saveState();
//! @brief Set the lock status of the patcher view.
void setLock(bool locked);
//! @brief Get the lock status of the patcher view.
bool isLocked() const;
//! @brief Returns a list of Users that selected an object.
std::set<uint64_t> getDistantSelection(ObjectFrame const& object) const;
//! @brief Returns true if the object is selected.
bool isSelected(ObjectFrame const& object) const;
//! @brief Returns true if the link is selected.
bool isSelected(LinkView const& link) const;
//! @brief Returns the Viewport that contains this patcher view.
//! @details You must use this method if you want to add this component into an other one.
PatcherViewport& useViewport();
//! @brief Returns the Viewport that contains this patcher view.
//! @details You must use this method if you want to add this component into an other one.
PatcherViewport const& useViewport() const;
//! @brief Returns the position of the patcher origin relative to the component position.
juce::Point<int> getOriginPosition() const;
//! @brief Call this to switch the box to edit mode
//! @details Will result in objectEdited being called in case of success.
void editObject(ObjectFrame & object_frame);
//! @brief Called when the object has entered edition mode.
void objectEditorShown(ObjectFrame const& object_frame);
//! @brief Called once an object's text has changed.
void objectTextChanged(ObjectFrame const& object_frame, std::string const& new_text);
//! @brief Called when the object is quitting edition mode.
void objectEditorHidden(ObjectFrame const& object_frame);
//! @brief Returns true if an object if being edited.
bool isEditingObject() const;
// ================================================================================ //
// COMPONENT //
// ================================================================================ //
void paint(juce::Graphics& g) override;
void mouseDown(juce::MouseEvent const& event) override;
void mouseDrag(juce::MouseEvent const& e) override;
void mouseUp(juce::MouseEvent const& e) override;
void mouseMove(juce::MouseEvent const& event) override;
void mouseDoubleClick(const juce::MouseEvent& event) override;
bool keyPressed(const juce::KeyPress& key) override;
// ================================================================================ //
// APPLICATION COMMAND TARGET //
// ================================================================================ //
juce::ApplicationCommandTarget* getNextCommandTarget() override;
void getAllCommands(juce::Array<juce::CommandID>& commands) override;
void getCommandInfo(juce::CommandID commandID, juce::ApplicationCommandInfo& result) override;
bool perform(const InvocationInfo& info) override;
private: // methods
//! @brief Set patcherview bounds relative to the screen
void setScreenBounds(juce::Rectangle<int> bounds);
//! @brief Called internally when the origin of the patcher view changed.
void originPositionChanged();
// ================================================================================ //
// PATCHER MANAGER LISTENER //
// ================================================================================ //
//! @brief Called when one or more users are connecting or disconnecting to the Patcher Document.
void connectedUserChanged(PatcherManager& manager) override;
// ================================================================================ //
// MODEL OBSERVER //
// ================================================================================ //
//! @brief Notify PatcherView that selection has changed.
void selectionChanged();
//! @brief Load object and links.
void loadPatcher();
//! @brief Check patcher view information changes (lock_status...).
void checkViewInfos(model::Patcher::View& view);
//! @brief Check the patcher objects selection changes.
void checkObjectsSelectionChanges(model::Patcher& patcher);
//! @brief Check the patcher objects selection changes.
void checkLinksSelectionChanges(model::Patcher& patcher);
//! @internal Object model has just been added to the document.
void addObjectView(model::Object& object, int zorder = -1);
//! @internal Object model is resident and internal value changed.
void objectChanged(model::Patcher::View& view, model::Object& object);
//! @internal Updates the object's view parameters.
void updateParameters(model::Patcher const& patcher);
//! @internal Object model will be removed from the document.
void removeObjectView(model::Object& object);
//! @internal Link model has just been added to the document.
void addLinkView(model::Link& link);
//! @internal Link model is resident and internal value changed.
void linkChanged(model::Link& link);
//! @internal Link model will be removed from the document.
void removeLinkView(model::Link& link);
//! @brief Add a new object's model at current mouse position and optionally give it focus.
void createObjectModel(std::string const& text, bool give_focus);
// ================================================================================ //
// UNDO/REDO //
// ================================================================================ //
//! @internal Try to undo last action.
void undo();
//! @internal Returns true if there is an action to undo.
bool canUndo();
//! @internal Returns the undo label if there is an action to undo or an empty string.
std::string getUndoLabel();
//! @internal Try to redo next action.
void redo();
//! @internal Returns true if there is an action to undo.
bool canRedo();
//! @internal Returns the redo label if there is an action to redo or an empty string.
std::string getRedoLabel();
// ================================================================================ //
// SELECTION //
// ================================================================================ //
//! @brief Returns the selected objects.
std::set<flip::Ref> const& getSelectedObjects() const;
//! @brief Returns the selected links.
std::set<flip::Ref> const& getSelectedLinks() const;
void addToSelectionBasedOnModifiers(ObjectFrame& object, bool select_only);
void addToSelectionBasedOnModifiers(LinkView& link, bool select_only);
bool selectOnMouseDown(ObjectFrame& object, bool select_only);
bool selectOnMouseDown(LinkView& link, bool select_only);
void selectOnMouseUp(ObjectFrame& box, bool select_only,
const bool box_was_dragged,
const bool result_of_mouse_down_select_method);
void selectOnMouseUp(LinkView& link, bool select_only,
const bool box_was_dragged,
const bool result_of_mouse_down_select_method);
//! @brief Returns true if any object or link is selected
bool isAnythingSelected();
//! @brief Returns true if there is at least one object selected
bool isAnyObjectSelected();
//! @brief Returns true if there is at least one link selected
bool isAnyLinksSelected();
//! @brief Select an Object.
void selectObject(ObjectFrame& object);
//! @brief Select multiple objects
void selectObjects(std::vector<ObjectFrame*> const& objects);
//! @brief Unselect all and select an object.
void selectObjectOnly(ObjectFrame& object);
//! @brief Select a Link.
void selectLink(LinkView& link);
//! @brief Select multiple links
void selectLinks(std::vector<LinkView*> const& links);
//! @brief Unselect all and select a link.
void selectLinkOnly(LinkView& link);
//! @brief Unselect an Object.
void unselectObject(ObjectFrame& object);
//! @brief Unselect a Link.
void unselectLink(LinkView& link);
//! @brief Add all objects to the patcher selection.
void selectAllObjects();
//! @brief Unselect all objects.
void unselectAll();
//! @brief Unselect all objects.
void deleteSelection();
//! @brief Move selected objects by a given amount of pixels.
//! @param delta The given amount of pixel.
//! @param commit Pass false if you don't want to commit.
//! @param gesture Pass true to commit a gesture (commit must be true).
void moveSelectedObjects(juce::Point<int> const& delta,
bool commit = true, bool gesture = false);
//! @brief Add selected objects and links to clipboard.
void copySelectionToClipboard();
//! @brief Try to paste clipboard content.
void pasteFromClipboard(juce::Point<int> const& delta);
//! @brief Duplicate selected objects.
void duplicateSelection();
//! @brief Copy selected objects then delete selection.
void cut();
//! @brief Try to replace selected object by the object copied into clipboard.
void pasteReplace();
//! @brief Replace an object by another one (trying to reconnect links)
model::Object& replaceObjectWith(model::Object& object_to_remove, model::Object& new_object);
// ================================================================================ //
// MISC //
// ================================================================================ //
//! @internal Finds an ObjectFrame with a given Object model.
ObjectFrames::iterator findObject(model::Object const& object);
//! @internal Finds a LinkView with a given Link model.
LinkViews::iterator findLink(model::Link const& link);
//! @internal Returns true if a link can be created between two objects.
bool canConnect(model::Object const& from, const size_t outlet,
model::Object const& to, const size_t inlet) const;
//! @internal Returns the current objects area.
juce::Rectangle<int> getCurrentObjectsArea();
//! @internal Returns the current selection bounds.
juce::Rectangle<int> getSelectionBounds();
//! @internal get the nearest valid iolet of the link creator.
std::pair<ObjectFrame*, size_t> getLinkCreatorNearestEndingIolet();
//! @brief Zoom in Patcher View.
void zoomIn();
//! @brief Zoom out Patcher View.
void zoomOut();
//! @brief Reset Patcher View zoom to 100%.
void zoomNormal();
//! @brief React to the openObjectHelp command.
void openObjectHelp();
//! @internal Show Patcher contextual Popup menu
void showPatcherPopupMenu(juce::Point<int> const& position);
//! @internal Show Object contextual popup menu
//! @details Will only show up when the patcher view is unlocked.
void showObjectPopupMenu(ObjectFrame const& object_view, juce::Point<int> const& position);
//! @internal Show Link contextual Popup menu
//! @details Will only show up when the patcher view is unlocked.
void showLinkPopupMenu(LinkView const& link_view, juce::Point<int> const& position);
//! @brief Bring all link components in front of object ones.
void bringsLinksToFront();
//! @brief Bring all object components in front of link ones.
void bringsObjectsToFront();
private: // members
PatcherManager& m_manager;
Instance& m_instance;
model::Patcher& m_patcher_model;
model::Patcher::View& m_view_model;
ObjectFrames m_objects;
LinkViews m_links;
std::set<flip::Ref> m_local_objects_selection;
std::set<flip::Ref> m_local_links_selection;
std::map<flip::Ref, std::set<uint64_t>> m_distant_objects_selection;
std::map<flip::Ref, std::set<uint64_t>> m_distant_links_selection;
std::unique_ptr<PatcherViewport> m_viewport = nullptr;
HitTester m_hittester;
MouseHandler m_mouse_handler;
IoletHighlighter m_io_highlighter;
Lasso m_lasso;
std::unique_ptr<LinkViewCreator> m_link_creator;
ObjectFrame const* m_box_being_edited = nullptr;
bool m_is_locked = false;
int m_grid_size;
friend MouseHandler;
friend PatcherViewport;
friend Lasso;
};
}
| 18,850
|
C++
|
.h
| 300
| 49.306667
| 106
| 0.551362
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,622
|
KiwiApp_ObjectView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <set>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiTool/KiwiTool_Parameter.h>
#include <KiwiTool/KiwiTool_Scheduler.h>
#include <KiwiModel/KiwiModel_Object.h>
namespace kiwi
{
class ObjectFrame;
class PatcherView;
// ================================================================================ //
// OBJECT VIEW //
// ================================================================================ //
//! @brief Abstract for objects graphical representation.
class ObjectView
: public juce::Component
, public juce::ComponentBoundsConstrainer
, public model::Object::Listener
{
public: // classes
enum ColourIds
{
PinControl = 0x1100013,
PinSignal = 0x1100015,
Background = 0x1100024,
Error = 0x1100025,
Text = 0x1100026,
Outline = 0x1100027,
Highlight = 0x1100028,
Active = 0x1100029
};
public: // methods
//! @brief Constructor.
ObjectView(model::Object& object_model);
//! @brief Destructor.
virtual ~ObjectView();
//! @brief Returns the model represented by the graphical object.
model::Object& getModel() const;
//! @brief Called when one of the model's attributes has changed.
void modelAttributeChanged(std::string const& name, tool::Parameter const& param) override final;
//! @brief Called when a parameter has changed.
void modelParameterChanged(std::string const& name, tool::Parameter const& param) override final;
//! @brief Called every time a patcher is locked or unlocked.
virtual void lockStatusChanged(bool is_locked);
//! @brief Get the resizing Flag as a set of border.
//! @see HitTester::Border
int getResizingFlags() const;
//! @brief Returns true if the box can grow horizontally
bool canGrowHorizontally() const;
//! @brief Returns true if the box can grow vertically
bool canGrowVertically() const;
protected: // methods
//! @brief Pass true if the box can grow horizontally
void canGrowHorizontally(bool can);
//! @brief Pass true if the box can grow vertically
void canGrowVertically(bool can);
//! @biref Returns the main scheduler.
tool::Scheduler<> & getScheduler() const;
//! @brief Defers a task on the main thread.
//! @details The task is automatically unscheduled when object is destroyed.
void defer(std::function<void()> call_back);
//! @brief Schedules a task on the main thread.
//! @details The tasks is automatically unscheduled when object is destroyed.
void schedule(std::function<void()> call_back, tool::Scheduler<>::duration_t delay);
//! @brief Draws the outlines of the object.
virtual void drawOutline(juce::Graphics & g);
//! @brief Changes one of the data model's attribute.
void setAttribute(std::string const& name, tool::Parameter const& param);
//! @brief Changes one of the data model's parameter.
void setParameter(std::string const& name, tool::Parameter const& param);
private: // methods
//! @brief Override this function if you want it to have a customied outline.
//! @details Used to draw the object's outline. Returns the object's bounds by default.
//! @todo May make it return path instead.
virtual juce::Rectangle<int> getOutline() const;
//! @brief Called once one of the data model's attributes has changed.
virtual void attributeChanged(std::string const& name, tool::Parameter const& param);
//! @brief Called once the data model's parameters has changed.
virtual void parameterChanged(std::string const& name, tool::Parameter const& param);
private: // members
model::Object& m_model;
std::shared_ptr<ObjectView> m_master;
int m_resizing_flags;
private: // deleted methods
ObjectView() = delete;
ObjectView(ObjectView const& other) = delete;
ObjectView(ObjectView && other) = delete;
ObjectView& operator=(ObjectView const& other) = delete;
ObjectView& operator=(ObjectView && other) = delete;
};
}
| 5,739
|
C++
|
.h
| 105
| 43.866667
| 106
| 0.5912
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,623
|
KiwiApp_Objects.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_Objects.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ClassicView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_SliderView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ToggleView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_MeterTildeView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_MessageView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_CommentView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h>
| 1,492
|
C++
|
.h
| 24
| 58.791667
| 91
| 0.665975
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,624
|
KiwiApp_CommentView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_CommentView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiModel/KiwiModel_Objects/KiwiModel_Message.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h>
namespace kiwi {
// ================================================================================ //
// COMMENT VIEW //
// ================================================================================ //
//! @brief The *comment* object view.
class CommentView
: public EditableObjectView
, public juce::TextEditor::Listener
{
public: // methods
// @brief The declaration method.
static void declare();
//! @brief Creation method.
static std::unique_ptr<ObjectView> create(model::Object & object_model);
//! @brief Constructor.
CommentView(model::Object & object_model);
//! @brief Destructor.
~CommentView();
private: // methods
//! @brief Called every time a patcher is locked or unlocked.
void lockStatusChanged(bool is_locked) override;
//! @brief Called when the text is being typed.
//! @details Used to resize in order to keep text visible.
void textEditorTextChanged(juce::TextEditor& editor) override final;
//! @brief Paints elements over the text editor.
void paintOverChildren (juce::Graphics& g) override final;
//! @brief Called whenever one of the object's attribute has changed.
void attributeChanged(std::string const& name, tool::Parameter const& param) override final;
//! @brief Called when the label text has changed.
//! @details Overrides EditableObjectView::textChanged.
void textChanged() override final;
//! @brief Constructs the label's text editor.
//! @details Overrides EditableOjectView::createTextEditor.
juce::TextEditor* createdTextEditor() override final;
private: // variables
bool m_patcher_view_locked {false};
private: // deleted methods
CommentView() = delete;
CommentView(CommentView const& other) = delete;
CommentView(CommentView && other) = delete;
CommentView& operator=(CommentView const& other) = delete;
CommentView& operator=(CommentView && other) = delete;
};
}
| 3,446
|
C++
|
.h
| 62
| 45.935484
| 101
| 0.582318
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,625
|
KiwiApp_NumberTildeView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberTildeView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h>
namespace kiwi {
// ================================================================================ //
// NUMBER TILDE VIEW //
// ================================================================================ //
//! @brief The view of any textual kiwi object.
class NumberTildeView : public NumberViewBase
{
public: // methods
// @brief The declaration method.
static void declare();
//! @brief Creation method.
static std::unique_ptr<ObjectView> create(model::Object & object_model);
//! @brief Constructor.
NumberTildeView(model::Object & object_model);
//! @brief Destructor.
~NumberTildeView();
private: // methods
void drawIcon (juce::Graphics& g) const override;
//! @brief Called when the displayed number has just changed.
void displayNumberChanged(double new_number) override final;
//! @brief Called whenever one of the object's attribute has changed.
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
private: // deleted methods
NumberTildeView() = delete;
NumberTildeView(NumberTildeView const&) = delete;
NumberTildeView(NumberTildeView && other) = delete;
NumberTildeView& operator=(NumberTildeView const& other) = delete;
NumberTildeView& operator=(NumberTildeView && other) = delete;
};
}
| 2,545
|
C++
|
.h
| 46
| 47.5
| 100
| 0.56801
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,626
|
KiwiApp_EditableObjectView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiTool/KiwiTool_Listeners.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
namespace kiwi
{
// ================================================================================ //
// EDITABLE OBJECT VIEW //
// ================================================================================ //
//! @brief Abstract class for object's views that can be edited in mode unlock.
class EditableObjectView
: public ObjectView
, public juce::Label::Listener
{
public: // classes
struct Listener;
public: // methods
//! @brief Constructor.
//! @details The label is not a child component by default, initialised with not text.
EditableObjectView(model::Object & object_model);
//! @brief Destructor.
~EditableObjectView();
//! @brief Add a listener.
void addListener(Listener& listener);
//! @brief Remove a listener.
void removeListener(Listener& listener);
//! @brief Edits the label.
void edit();
//! @brief Set a new text.
void setText(juce::String const& new_text);
//! @brief Get the text.
juce::String getText() const;
//! @brief Set a new font.
void setFont(juce::Font font);
//! @brief Get the current font used by the box.
juce::Font getFont() const;
//! @brief Set a padding value.
void setPadding(int padding);
//! @brief Get the current padding value.
int getPadding() const;
//! @brief Check Component bounds.
void checkBounds (juce::Rectangle<int>& bounds,
juce::Rectangle<int> const& previousBounds,
juce::Rectangle<int> const& limits,
bool isStretchingTop,
bool isStretchingLeft,
bool isStretchingBottom,
bool isStretchingRight) override;
//! @brief Get the minimum height.
//! @details The minimum height is (font_height + 2 * padding)
int getMinHeight() const;
//! @brief Get the minimum width.
//! @details The minimum width is (font_height + 2 * padding)
int getMinWidth() const;
private: // classes
class Label : public juce::Label
{
public: // methods
//! @brief Constructor.
Label(EditableObjectView & object_view);
//! @brief Destructor.
~Label();
//! @brief Called to create the text editor once edit is called.
juce::TextEditor* createEditorComponent() override final;
void paint(juce::Graphics& g) override;
private: // members
EditableObjectView & m_object_view;
};
protected: // methods
//! @brief Called when the object is resized.
//! @details Default implementation apply local bounds to the label.
virtual void resized() override;
//! @brief Returns the label created by the editable object.
juce::Label & getLabel();
//! @brief Sets the editable object view as editable or not.
//! @details Editable object is editable by default.
void setEditable(bool editable);
//! @brief Try to find the bounding bow of a text
//! @details This is a default implementation,
//! subclasses can override this method if they need.
virtual juce::Rectangle<float> getTextBoundingBox(juce::String const& text,
float max_width) const;
private: // methods
void paint(juce::Graphics& g) override;
void drawLabel(juce::Graphics& g);
//! @brief Creates the text editor used by label when it's edited.
virtual juce::TextEditor* createdTextEditor() = 0;
//! @brief Called when the label text has changed before calling observers.
virtual void textChanged() = 0;
//! @brief Called when the label text has changed.
//! @details Overrides juce::Label::labelTextChanged.
void labelTextChanged (juce::Label* label) override final;
//! @brief Called when edition ends.
//! @details Overrides juce::Label::editorHidden.
void editorHidden (juce::Label* label, juce::TextEditor& text_editor) override final;
//! @brief Called when edition begins.
//! @details Overrides juce::Label::editorShown.
void editorShown(juce::Label* label, juce::TextEditor& text_editor) override final;
private: // members
Label m_label;
bool m_editable {true};
tool::Listeners<Listener> m_listeners;
int m_padding {3};
private: // deleted methods
EditableObjectView() = delete;
EditableObjectView(EditableObjectView const& other) = delete;
EditableObjectView(EditableObjectView && other) = delete;
EditableObjectView& operator=(EditableObjectView const& other) = delete;
EditableObjectView& operator=(EditableObjectView && other) = delete;
};
struct EditableObjectView::Listener
{
//! @brief Destructor.
virtual ~Listener() = default;
//! @brief Called when the text has been edited and return key was pressed.
virtual void textChanged(std::string const& new_text) = 0;
//! @brief Called when the classic view ends its edition.
virtual void editorHidden() = 0;
//! @brief Called when the classic view enters its edition mode.
virtual void editorShown() = 0;
};
}
| 7,121
|
C++
|
.h
| 135
| 40.066667
| 95
| 0.57638
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,627
|
KiwiApp_MeterTildeView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_MeterTildeView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <vector>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
namespace kiwi {
// ================================================================================ //
// METER~ VIEW //
// ================================================================================ //
class MeterTildeView : public ObjectView
{
private: // classes
struct Led
{
float min_db {0.f};
juce::Colour colour {};
juce::Rectangle<float> bounds {};
};
public: // methods
static void declare();
static std::unique_ptr<ObjectView> create(model::Object & model);
MeterTildeView(model::Object & object_model);
~MeterTildeView();
private: // methods
void resized() override final;
void paint(juce::Graphics & g) override final;
void peakChanged(float new_peak);
juce::Colour computeGradientColour(float delta) const;
void computeActiveLed(float peak_db);
private: // members
std::vector<Led> m_leds {};
int m_active_led = -1;
juce::Colour m_cold_colour = juce::Colour(0xff04047f);
juce::Colour m_hot_colour = juce::Colour(0xffca2423);
float m_led_distance = 1.f;
float m_padding = 4.f;
flip::SignalConnection m_connection {};
private: // deleted methods
MeterTildeView() = delete;
MeterTildeView(MeterTildeView const& other) = delete;
MeterTildeView(MeterTildeView && other) = delete;
MeterTildeView& operator=(MeterTildeView const& other) = delete;
MeterTildeView& operator=(MeterTildeView && other) = delete;
};
}
| 2,942
|
C++
|
.h
| 58
| 41.862069
| 90
| 0.526723
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,628
|
KiwiApp_MessageView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_MessageView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiModel/KiwiModel_Objects/KiwiModel_Message.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h>
namespace kiwi {
// ================================================================================ //
// MESSAGE VIEW //
// ================================================================================ //
//! @brief The *message* object view.
class MessageView
: public EditableObjectView
, public juce::TextEditor::Listener
{
public: // methods
// @brief The declaration method.
static void declare();
//! @brief Creation method.
static std::unique_ptr<ObjectView> create(model::Object & object_model);
//! @brief Constructor.
MessageView(model::Object & object_model);
//! @brief Destructor.
~MessageView();
private: // methods
//! @brief Called when the message is clicked.
void mouseDown(juce::MouseEvent const& e) override;
//! @brief Called when the bang is unclicked.
void mouseUp(juce::MouseEvent const& e) override;
//! @brief Called when the text is being typed.
//! @details Used to resize in order to keep text visible.
void textEditorTextChanged(juce::TextEditor& editor) override;
void paint(juce::Graphics& g) override;
//! @brief Paints elements over the text editor.
void paintOverChildren (juce::Graphics& g) override;
//! @brief Called whenever one of the object's attribute has changed.
void attributeChanged(std::string const& name, tool::Parameter const& param) override;
//! @brief Called when the label text has changed.
//! @details Overrides EditableObjectView::textChanged.
void textChanged() override;
//! @brief Constructs the label's text editor.
//! @details Overrides EditableOjectView::createTextEditor.
juce::TextEditor* createdTextEditor() override;
private: // members
flip::Signal<> & m_output_message;
bool m_active;
private: // deleted methods
MessageView() = delete;
MessageView(MessageView const& other) = delete;
MessageView(MessageView && other) = delete;
MessageView& operator=(MessageView const& other) = delete;
MessageView& operator=(MessageView && other) = delete;
};
}
| 3,635
|
C++
|
.h
| 66
| 44.969697
| 95
| 0.575893
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,629
|
KiwiApp_ToggleView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ToggleView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
namespace kiwi {
// ================================================================================ //
// TOGGLE VIEW //
// ================================================================================ //
class ToggleView : public ObjectView
{
public: // methods
static void declare();
static std::unique_ptr<ObjectView> create(model::Object & model);
ToggleView(model::Object & object_model);
~ToggleView();
private: // methods
void paint(juce::Graphics & g) override final;
void mouseDown(juce::MouseEvent const& e) override final;
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
private: // members
flip::Signal<> & m_signal;
bool m_is_on;
private: // deleted methods
ToggleView() = delete;
ToggleView(ToggleView const& other) = delete;
ToggleView(ToggleView && other) = delete;
ToggleView& operator=(ToggleView const& other) = delete;
ToggleView& operator=(ToggleView && other) = delete;
};
}
| 2,325
|
C++
|
.h
| 42
| 45.714286
| 101
| 0.51763
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,630
|
KiwiApp_NumberView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h>
namespace kiwi {
// ================================================================================ //
// NUMBER VIEW //
// ================================================================================ //
//! @brief The view of any textual kiwi object.
class NumberView : public NumberViewBase
{
public: // methods
// @brief The declaration method.
static void declare();
//! @brief Creation method.
static std::unique_ptr<ObjectView> create(model::Object & object_model);
//! @brief Constructor.
NumberView(model::Object & object_model);
//! @brief Destructor.
~NumberView();
private: // methods
void drawIcon (juce::Graphics& g) const override;
//! @brief Stores the initial value before draging.
void mouseDown(juce::MouseEvent const& e) override final;
//! @brief Increment value depending on mouse position.
void mouseDrag(juce::MouseEvent const& e) override final;
//! @brief Resets mouse information.
void mouseUp(juce::MouseEvent const& e) override final;
//! @brief Edits the label.
void mouseDoubleClick(juce::MouseEvent const& e) override final;
//! @brief Called whenever one of the object's attribute has changed.
void parameterChanged(std::string const& name, tool::Parameter const& param) override final;
//! @brief Sets the parameter value.
void displayNumberChanged(double number) override final;
private: // members
flip::Signal<>& m_output_message;
int m_decimal_drag = 0;
juce::Point<float> m_last_drag_pos {};
double m_drag_value = 0;
private: // deleted methods
NumberView() = delete;
NumberView(NumberView const& other) = delete;
NumberView(NumberView && other) = delete;
NumberView& operator=(NumberView const& other) = delete;
NumberView& operator=(NumberView && other) = delete;
};
}
| 3,214
|
C++
|
.h
| 60
| 44.75
| 100
| 0.575453
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,631
|
KiwiApp_ClassicView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ClassicView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <functional>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiModel/KiwiModel_Object.h>
#include <KiwiTool/KiwiTool_Listeners.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h>
namespace kiwi
{
// ================================================================================ //
// CLASSIC VIEW //
// ================================================================================ //
//! @brief The view of any textual kiwi object.
class ClassicView : public EditableObjectView,
public juce::TextEditor::Listener
{
public: // methods
//! @brief Constructor.
ClassicView(model::Object & object_model);
//! @brief Destructor.
~ClassicView();
private: // methods
//! @brief Constructs the label's text editor.
//! @brief Overrides EditableObjectView::createTextEditor.
juce::TextEditor* createdTextEditor() override;
//! @brief Called when label text changed.
//! @details Overrides EditableObjectView::textChanged.
void textChanged() override;
//! @brief Called when the text is being typed.
//! @details Used to resize in order to keep text visible.
void textEditorTextChanged(juce::TextEditor& editor) override;
//! @brief Paints elements over the text editor.
void paintOverChildren (juce::Graphics& g) override;
private: // deleted methods
ClassicView() = delete;
ClassicView(ClassicView const& other) = delete;
ClassicView(ClassicView && other) = delete;
ClassicView& operator=(ClassicView const& other) = delete;
ClassicView& operator=(ClassicView && other) = delete;
};
}
| 2,857
|
C++
|
.h
| 54
| 44.185185
| 91
| 0.562617
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,632
|
KiwiApp_ObjectFrame.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectFrame.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <memory>
#include <string>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiModel/KiwiModel_Patcher.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h>
#include <KiwiApp_Patcher/KiwiApp_PatcherView.h>
namespace kiwi
{
// ================================================================================ //
// OBJECT FRAME //
// ================================================================================ //
//! @brief A juce component holding the object's graphical representation.
//! @details ObjectFrame is implemented as a wrapper around an object view that displays
//! selections and outlet and handle certain interactions.
class ObjectFrame
: public juce::Component
, public EditableObjectView::Listener
{
public: // methods
//! @brief Constructor.
ObjectFrame(PatcherView& patcher_view, std::unique_ptr<ObjectView> object_view);
//! @brief Destructor.
~ObjectFrame();
//! @brief Called whenever an object's model has changed.
void objectChanged(model::Patcher::View& view, model::Object& object);
//! @brief Updates the inner object's view attributes.
void attributeChanged(std::string const& name, tool::Parameter const& parameter);
//! @brief Called whenever the client wants to edit an object.
//! @details Will only edit the object if its a textual object.
void editObject();
//! @brief Called by the patcher every time the selection status of this object has changed.
//! @details Function called when local selection or distant selection has changed.
void selectionChanged();
//! @brief Called every time a patcher is locked or unlocked.
void lockStatusChanged();
//! @brief Called when the patcher's origin changes.
void patcherViewOriginPositionChanged();
//! @brief Returns The object's bounds relative to the patcher position.
juce::Rectangle<int> getObjectBounds() const;
//! @brief Returns the inlet position relative to the parent PatcherView component for a given index.
juce::Point<int> getInletPatcherPosition(const size_t index) const;
//! @brief Returns the outlet position relative to the parent PatcherView component for a given index.
juce::Point<int> getOutletPatcherPosition(const size_t index) const;
//! @brief Returns the object's model.
model::Object& getModel() const;
//! @brief Overloaded from juce::Component to exclude border size.
bool hitTest(int x, int y) override;
//! @brief Internal kiwi PatcherView HitTesting.
bool hitTest(juce::Point<int> const& pt, HitTester& result) const;
//! @brief Internal kiwi PatcherView HitTesting (overlaps a rectangle).
bool hitTest(juce::Rectangle<int> const& rect) const;
//! @brief Returns true if the object is selected.
bool isSelected() const;
//! @brief Called when object's frame is clicked.
void mouseDown(juce::MouseEvent const& e) override final;
//! @brief Called when object's frame is clicked.
void mouseUp(juce::MouseEvent const& e) override final;
//! @brief Called when object's frame is clicked.
void mouseDrag(juce::MouseEvent const& e) override final;
//! @brief Get the ComponentBoundsConstrainer.
juce::ComponentBoundsConstrainer* getBoundsConstrainer() const;
//! @brief Get the resizing Flag as a set of border.
//! @see HitTester::Border
int getResizingFlags() const;
public: // classes
struct Outline : public juce::Component
{
public: // classes
enum Border : int
{
Top = 1 << 0,
Bottom = 1 << 1,
Left = 1 << 2,
Right = 1 << 3
};
public: // methods
//! @brief Constructor.
Outline(int resize_length, int resize_thickness);
using juce::Component::hitTest; // silent virtual function overload hiding warning
//! @brief Tests if the point reaches an interactive resiable corner.
bool hitTest(juce::Point<int> const& pt, HitTester& hit_tester) const;
//! @brief Returns the corner border width.
int getBorderThickness() const;
//! @brief Returns the corner border length.
int getResizeLength() const;
~Outline();
private: // methods
//! @brief Draws a corner.
void drawCorner(juce::Graphics & g, Border border);
//! @brief Graphical rendering method.
void paint(juce::Graphics & g) override final;
//! @brief Call once size changed. Recompute borders and corners position.
void resized() override final;
//! @brief Update the corners position
void updateCorners();
private: // members
int m_resize_length;
int m_resize_thickness;
std::map<Border, std::array<juce::Rectangle<float>, 3>> m_corners;
};
private: // methods
//! @brief Paints outlets, inlets over child component.
void paintOverChildren (juce::Graphics& g) override final;
//! @brief Called whenever the object's size changes.
void resized() override final;
//! @brief Called once a ClassicView's text has changed.
void textChanged(std::string const& new_text) override final;
//! @brief Called when the classic view ends its edition.
void editorHidden() override final;
//! @brief Called when the classic view enters its edition mode.
void editorShown() override final;
//! @brief Called to update the bounds of the object.
void updateBoundsFromModel(bool animate);
//! @brief Updates the outline according to the selection status.
//! @details Makes it visible or not and updates its colour.
void updateOutline();
//! @brief Called when the object's view size has changed.
//! @details The obect frame adapts to fit the underlying object's size.
void childBoundsChanged(juce::Component * child) override final;
//! @brief Returns the patcher view component.
PatcherView& getPatcherView() const;
//! @brief Returns a list of Users that selected an object.
std::set<uint64_t> getDistantSelection() const;
//! @brief Returns the number of inlets
size_t getNumberOfInlets() const noexcept;
//! @brief Returns the number of outlets
size_t getNumberOfOutlets() const noexcept;
//! @brief Update the inlets
void updateInlets(model::Object const& object);
//! @brief Update the outlets
void updateOutlets(model::Object const& object);
//! @brief Draws the inlets/outlets of the object.
void drawInletsOutlets(juce::Graphics & g);
//! @brief Returns the inlet local bounds for a given index.
juce::Rectangle<int> getInletLocalBounds(const size_t index) const;
//! @brief Returns the outlet local bounds for a given index.
juce::Rectangle<int> getOutletLocalBounds(const size_t index) const;
//! @brief Returns the width of any outlet/inlet represented in the object's frame.
size_t getPinWidth() const;
//! @brief Returns the height of any outlet/inlet represented in the object's frame.
size_t getPinHeight() const;
//! @brief Returns true if the object is locked.
bool isLocked() const;
private: // members
struct Pin
{
Pin(bool pin_is_signal)
: is_signal(pin_is_signal)
{}
bool is_signal {false};
};
std::unique_ptr<ObjectView> m_object_view;
PatcherView& m_patcher_view;
const size_t m_io_width;
const size_t m_io_height;
std::vector<Pin> m_inlets;
std::vector<Pin> m_outlets;
Outline m_outline;
private: // deleted methods
ObjectFrame() = delete;
ObjectFrame(ObjectFrame const& other) = delete;
ObjectFrame(ObjectFrame && other) = delete;
ObjectFrame& operator=(ObjectFrame const& other) = delete;
ObjectFrame& operator=(ObjectFrame && other) = delete;
};
}
| 10,212
|
C++
|
.h
| 181
| 44.248619
| 110
| 0.608784
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,633
|
KiwiApp_SliderView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_SliderView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <memory>
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
namespace kiwi
{
// ================================================================================ //
// SLIDER VIEW //
// ================================================================================ //
class SliderView : public ObjectView, juce::Slider::Listener
{
private: // classes
class Task;
public: // methods
SliderView(model::Object & object_model);
~SliderView();
static void declare();
static std::unique_ptr<ObjectView> create(model::Object & object);
private: // methods
void sliderValueChanged(juce::Slider * slider) override final;
void paint(juce::Graphics & g) override final;
void mouseDown(juce::MouseEvent const& e) override final;
void mouseUp(juce::MouseEvent const& e) override final;
void mouseDrag(juce::MouseEvent const& e) override final;
void resized() override final;
void parameterChanged(std::string const& name, tool::Parameter const& parameter) override final;
void valueChanged(double new_value);
private: // members
juce::Slider m_slider;
flip::Signal<> & m_output_value;
private: // delted methods
SliderView() = delete;
SliderView(SliderView const& other) = delete;
SliderView(SliderView && other) = delete;
SliderView& operator=(SliderView const& other) = delete;
SliderView& operator=(SliderView && other) = delete;
};
}
| 2,813
|
C++
|
.h
| 52
| 43.634615
| 105
| 0.552227
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,634
|
KiwiApp_NumberViewBase.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_NumberViewBase.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <juce_gui_basics/juce_gui_basics.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_EditableObjectView.h>
namespace kiwi {
// ================================================================================ //
// NUMBER VIEW BASE //
// ================================================================================ //
//! @brief The view of any textual kiwi object.
class NumberViewBase : public EditableObjectView
{
public: // methods
//! @brief Constructor.
NumberViewBase(model::Object & object_model);
//! @brief Destructor.
~NumberViewBase();
protected: // methods.
//! @brief Sets the displayed text and call repaint.
void setDisplayNumber(double number);
//! @brief Returns the displayed text as a number.
double getDisplayNumber() const;
virtual void drawIcon (juce::Graphics& g) const;
private: // methods
//! @brief Overrides this method to react to a change in display number.
virtual void displayNumberChanged(double number) = 0;
private: // methods
//! @brief Called when the object is resized.
void resized() override final;
//! @brief Draw the background of the number object.
void paint(juce::Graphics& g) override final;
//! @brief Paints elements over the text editor.
void paintOverChildren (juce::Graphics& g) override final;
//! @brief Called when the label text has changed.
//! @details Overrides EditableObjectView::textChanged.
void textChanged() override final;
//! @brief Constructs the label's text editor.
//! @details Overrides EditableOjectView::createTextEditor.
juce::TextEditor* createdTextEditor() override final;
protected: // members
double m_value;
int m_indent;
private: // deleted methods
NumberViewBase() = delete;
NumberViewBase(NumberViewBase const& other) = delete;
NumberViewBase(NumberViewBase && other) = delete;
NumberViewBase& operator=(NumberViewBase const& other) = delete;
NumberViewBase& operator=(NumberViewBase && other) = delete;
};
}
| 3,341
|
C++
|
.h
| 62
| 44.903226
| 90
| 0.581418
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,635
|
KiwiApp_BangView.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_BangView.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <memory>
#include <juce_graphics/juce_graphics.h>
#include <KiwiModel/KiwiModel_Object.h>
#include <KiwiApp_Patcher/KiwiApp_Objects/KiwiApp_ObjectView.h>
namespace kiwi {
// ================================================================================ //
// BANG VIEW //
// ================================================================================ //
class BangView : public ObjectView
{
public: // methods
static void declare();
static std::unique_ptr<ObjectView> create(model::Object & model);
BangView(model::Object & object_model);
~BangView();
private: // methods
void paint(juce::Graphics & g) override final;
void mouseDown(juce::MouseEvent const& e) override final;
void mouseUp(juce::MouseEvent const& e) override final;
void flash();
void signalTriggered();
private: // members
//! @todo Put border into ObjectView.
flip::Signal<>& m_trigger_signal;
flip::Signal<>& m_flash_signal;
flip::SignalConnection m_trigger_connection;
flip::SignalConnection m_flash_connection;
bool m_active;
bool m_mouse_down;
private: // deleted methods
BangView() = delete;
BangView(BangView const& other) = delete;
BangView(BangView && other) = delete;
BangView& operator=(BangView const& other) = delete;
BangView& operator=(BangView && other) = delete;
};
}
| 2,842
|
C++
|
.h
| 52
| 44.942308
| 91
| 0.496933
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,636
|
KiwiApp_DspDeviceManager.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Audio/KiwiApp_DspDeviceManager.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiDsp/KiwiDsp_Signal.h>
#include <KiwiDsp/KiwiDsp_Chain.h>
#include <KiwiEngine/KiwiEngine_AudioControler.h>
#include <juce_audio_devices/juce_audio_devices.h>
#include "../KiwiApp_Components/KiwiApp_Window.h"
namespace kiwi
{
// ================================================================================ //
// DSP DEVICE MANAGER //
// ================================================================================ //
class DspDeviceManager : public juce::AudioIODeviceCallback,
public juce::AudioDeviceManager,
public engine::AudioControler
{
public: // methods
//! @brief Constructor.
//! @details Initialized with saved audio settings if previously stored and with
//! @details default settings if not.
DspDeviceManager();
//! @brief Destructor.
~DspDeviceManager();
// ================================================================================ //
// AudioControler //
// ================================================================================ //
//! @brief Adds a chain to the dsp device manager
//! @details If the device is playing the chain will prepared before it's added
void add(dsp::Chain& chain) override;
//! @brief Removes a chain from the device manager.
//! @details The chain is removed and released since is tick method is no longer called.
void remove(dsp::Chain& chain) override;
//! @brief Starts the device.
void startAudio() override;
//! @brief Stops the device.
void stopAudio() override;
//! @brief Returns true if the audio is on.
bool isAudioOn() const override;
//! @brief Adds a buffer to the output matrix of signal.
void addToChannel(size_t const channel, dsp::Signal const& output_buffer) override;
//! @brief Gets a buffer from the input matrix signal.
void getFromChannel(size_t const channel, dsp::Signal & input_signal) override;
private: // methods
// ================================================================================ //
// AudioIODeviceCallback //
// ================================================================================ //
//! @internal Processes a block of incoming and outgoing audio data.
void audioDeviceIOCallback(const float** inputChannelData,
int numInputChannels,
float** outputChannelData,
int numOutputChannels,
int numSamples) override;
//! @internal Called to indicate that the device is about to start calling back.
void audioDeviceAboutToStart(juce::AudioIODevice* device) override;
//! @internal Called to indicate that the device has stopped.
void audioDeviceStopped() override;
// ================================================================================ //
// DSP DEVICE //
// ================================================================================ //
//! @brief Ticks all the chains.
//! @details Called at each dsp cycle.
void tick() const noexcept;
private: // members
std::unique_ptr<dsp::Buffer> m_input_matrix;
std::unique_ptr<dsp::Buffer> m_output_matrix;
std::vector<dsp::Chain*> m_chains;
bool m_is_playing;
mutable std::mutex m_mutex;
};
}
| 5,002
|
C++
|
.h
| 83
| 49.662651
| 96
| 0.468598
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,637
|
KiwiApp_AuthPanel.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Auth/KiwiApp_AuthPanel.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiApp_Components/KiwiApp_FormComponent.h>
#include <KiwiApp_Network/KiwiApp_Api.h>
namespace kiwi
{
// ================================================================================ //
// LOGIN FORM //
// ================================================================================ //
class LoginForm : public FormComponent
{
private: // classes
enum class State
{
Login,
Request,
Reset
};
public: // methods
//! @brief Constructor.
//! @details Creates a login form.
LoginForm();
//! @brief Destructor.
~LoginForm() = default;
private: // methods
//! @brief Sends login request to server.
void performLogin();
//! @brief Sends password token request to server.
void performPassReset();
//! @brief Sends password reset request to server.
void performPassRequest();
//! @brief When submit button clicked. Reaction depends on current state.
void onUserSubmit() override;
//! @brief When cancel button is clicked depends on current state.
void onUserCancelled() override;
//! @brief Change the form state.
void setState(State state);
private: // members
State m_state;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LoginForm)
};
// ================================================================================ //
// SIGNUP FORM //
// ================================================================================ //
class SignUpForm : public FormComponent
{
public: // methods
//! @brief Constructor.
//! @details Creates a signup form.
SignUpForm();
//! @brief Destructor.
~SignUpForm() = default;
private: // methods
void onUserSubmit() override;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SignUpForm)
};
// ================================================================================ //
// AUTH PANEL //
// ================================================================================ //
class AuthPanel
: public juce::TabbedComponent
, public juce::ComponentListener
{
public: // methods
enum FormType
{
Login = 0,
SignUp,
UserProfile,
None,
};
AuthPanel(FormType form_type = FormType::None);
~AuthPanel();
private: // methods
void updateSize(FormType type);
//! @brief Callback method to indicate the selected tab has been changed.
void currentTabChanged(int new_tab_index, juce::String const& new_tab_name) override;
void componentMovedOrResized(juce::Component& component,
bool wasMoved,
bool wasResized) override;
private: // variables
LoginForm m_login_form;
SignUpForm m_signup_form;
};
}
| 4,399
|
C++
|
.h
| 98
| 34.663265
| 93
| 0.475275
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,638
|
KiwiApp_SuggestList.h
|
Musicoll_Kiwi/Client/Source/KiwiApp_Utils/KiwiApp_SuggestList.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <string>
#include <algorithm>
#include <cctype> // ::tolower, ::toupper
#include <vector>
namespace kiwi
{
// ================================================================================ //
// SUGGEST LIST //
// ================================================================================ //
//! @brief A string container that provide suggestion list based on given patterns.
//! @details This class maintain
class SuggestList
{
public: // methods
using entries_t = std::vector<std::string>;
//! @brief Constructor.
SuggestList() = default;
//! @brief Constructor.
SuggestList(entries_t entries) :
m_options(),
m_entries(entries.begin(), entries.end()),
m_last_filter_pattern(""),
m_need_update(true)
{
updateFilteredEntries();
}
//! @brief Destructor.
~SuggestList() = default;
//! @brief Score bonuses and penalties to sort entries.
struct Options
{
Options() noexcept {}
// Score bonuses
int adjacency_bonus = 5; //! For adjacent matches.
// Score penalties
int leading_letter_penalty = -9; //! For every letter in str before the first match.
int max_leading_letter_penalty = -9; //! Maximum penalty for leading letters.
int unmatched_letter_penalty = -1; //! For every letter that doesn't matter.
};
// iterators
using iterator = entries_t::iterator;
using const_iterator = entries_t::const_iterator;
iterator begin() { return m_filtered_entries.begin(); }
iterator end() { return m_filtered_entries.end(); }
const_iterator begin() const { return m_filtered_entries.cbegin(); }
const_iterator end() const { return m_filtered_entries.cend(); }
//! @brief Set the sorting options.
void setOptions(Options options) { m_options = options; }
//! @brief Add a suggestion entry to the list.
//! @details This will also update the filtered list.
//! @see addEntries
void addEntry(std::string const& entry)
{
m_entries.emplace_back(entry);
updateFilteredEntries();
}
//! @brief Add suggestion entries to the list.
//! @details This will also update the filtered list.
//! @see addEntry
void addEntries(std::vector<std::string> const& entries)
{
m_entries.insert(m_entries.end(), entries.begin(), entries.end());
updateFilteredEntries();
}
//! @brief Returns the size of the current filtered selection
entries_t::size_type size() const noexcept { return m_filtered_entries.size(); }
//! @brief Returns true if there is no suggestion entry.
bool empty() const noexcept { return m_filtered_entries.empty(); }
//! @brief Clear all entries.
void clear() { m_entries.clear(); m_filtered_entries.clear(); }
//! @brief Returns the current filter pattern applied to the list
std::string const& getCurrentFilter() const { return m_last_filter_pattern; }
//! @brief Apply a pattern matching filter to the entries.
void applyFilter(std::string const& pattern)
{
if(m_need_update || (m_last_filter_pattern != pattern))
{
m_last_filter_pattern = pattern;
if(m_last_filter_pattern == "")
{
m_filtered_entries = m_entries;
return;
}
char const* pattern_cstr = m_last_filter_pattern.c_str();
struct ScoredEntry
{
ScoredEntry(std::string const& _str, int _score) : string(_str), score(_score) {}
bool operator<(ScoredEntry const& entry) const { return (score >= entry.score); }
std::string string = "";
int score = 0;
};
std::set<ScoredEntry> scored_entries;
for(auto const& str : m_entries)
{
const auto r = computeScore(pattern_cstr, str.c_str(), m_options);
if(r.first)
{
scored_entries.insert({str, r.second});
}
}
m_filtered_entries.clear();
for(auto const& scored_entry : scored_entries)
{
m_filtered_entries.emplace_back(std::move(scored_entry.string));
}
m_need_update = false;
}
}
//! @brief Returns true if each character in pattern is found sequentially within str
//! @details if found then score is also set.
//! Score value has no intrinsic meaning. Range varies with pattern.
//! You should only compare scores with same search pattern.
//! @remark The code of this method is an adaptation of the Forrest Smith code described in this article :
//! https://blog.forrestthewoods.com/reverse-engineering-sublime-text-s-fuzzy-match-4cffeed33fdb
static std::pair<bool, int> computeScore(char const* pattern, char const* str,
Options options = {})
{
int score = 0;
char const* pattern_iter = pattern;
char const* str_iter = str;
bool prev_matched = false;
// Use "best" matched letter if multiple string letters match the pattern
char const* best_letter = nullptr;
int best_letter_score = 0;
// Loop over chars
while(*str_iter != end_char)
{
const char pattern_letter = *pattern_iter;
const char str_letter = *str_iter;
const char pattern_letter_lower = std::tolower(pattern_letter);
const char str_letter_lower = std::tolower(str_letter);
const bool pattern_valid_char = (pattern_letter != end_char);
const bool next_match = pattern_valid_char && (pattern_letter_lower == str_letter_lower);
const bool rematch = best_letter && (std::tolower(*best_letter) == str_letter_lower);
const bool advanced = (next_match && best_letter);
const bool pattern_repeat = best_letter && pattern_valid_char && (std::tolower(*best_letter) == pattern_letter_lower);
if(advanced || pattern_repeat)
{
score += best_letter_score;
best_letter = nullptr;
best_letter_score = 0;
}
if(next_match || rematch)
{
int new_score = 0;
// Apply penalty for each letter before the first pattern match
if(pattern_iter == pattern)
{
const int count = static_cast<int>(str_iter - str);
int penalty = options.leading_letter_penalty * count;
if(penalty < options.max_leading_letter_penalty)
penalty = options.max_leading_letter_penalty;
score += penalty;
}
// Apply bonus for consecutive bonuses
if (prev_matched)
new_score += options.adjacency_bonus;
// Update pattern iter if the next pattern letter was matched
if (next_match)
++pattern_iter;
// Update best letter in str which may be for a "next" letter or a rematch
if (new_score >= best_letter_score)
{
// Apply penalty for now skipped letter
if (best_letter != nullptr)
score += options.unmatched_letter_penalty;
best_letter = str_iter;
best_letter_score = new_score;
}
prev_matched = true;
}
else
{
score += options.unmatched_letter_penalty;
prev_matched = false;
}
++str_iter;
}
// Apply score for last match
if(best_letter)
{
score += best_letter_score;
}
// Did not match full pattern
if(*pattern_iter != end_char)
{
return {false, 0};
}
return {true, score};
}
private: // methods
void updateFilteredEntries()
{
m_need_update = true;
applyFilter(m_last_filter_pattern);
}
private: // members
static constexpr char end_char = '\0';
Options m_options = {};
entries_t m_entries = {};
entries_t m_filtered_entries = {};
std::string m_last_filter_pattern = "";
bool m_need_update = true;
};
}
| 11,234
|
C++
|
.h
| 220
| 33.872727
| 135
| 0.498543
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,639
|
KiwiServer_CommandLineParser.h
|
Musicoll_Kiwi/Server/Source/KiwiServer_CommandLineParser.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <string>
namespace kiwi
{
//! @brief A simple command line parser
//! @details based on http://stackoverflow.com/questions/865668/how-to-parse-command-line-arguments-in-c/868894#868894
class CommandLineParser
{
public:
//! @brief Constructor.
//! @param argc Argument count.
//! @param argv Arguments.
CommandLineParser(int argc, char const* const* const argv)
{
for(int i=1; i < argc; ++i)
{
tokens.emplace_back(argv[i]);
}
}
//! @brief Destructor.
~CommandLineParser() = default;
//! @brief Get a command option or an empty string if the option is not found.
std::string const& getOption(std::string const& option) const
{
auto it = std::find(tokens.begin(), tokens.end(), option);
if (it != tokens.end() && ++it != tokens.end())
{
return *it;
}
return empty_string;
}
//! @brief Returns true if the command option exists.
bool hasOption(const std::string& option) const
{
return (std::find(tokens.begin(), tokens.end(), option) != this->tokens.end());
}
private: // variables
static const std::string empty_string;
std::vector<std::string> tokens;
};
const std::string CommandLineParser::empty_string = {""};
}
| 2,401
|
C++
|
.h
| 56
| 34.214286
| 122
| 0.564811
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,640
|
KiwiBenchmark.h
|
Musicoll_Kiwi/Test/KiwiBenchmark.h
|
/*
==============================================================================
This file is part of the KIWI library.
Copyright (c) 2014 Pierre Guillot & Eliott Paris.
Permission is granted to use this software under the terms of either:
a) the GPL v2 (or any later version)
b) the Affero GPL v3
Details of these licenses can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
To release a closed-source product which uses KIWI, contact : guillotpierre6@gmail.com
==============================================================================
*/
#ifndef KIWI_BENCHMARK_HPP_INCLUDED
#define KIWI_BENCHMARK_HPP_INCLUDED
#include <chrono>
#include <iostream>
class Benchmark
{
public:
using clock_t = std::chrono::system_clock;
using duration_t = std::chrono::duration<double>;
using timestamp_t = std::chrono::time_point<clock_t>;
//! @brief Sorting methods
enum class Sort : uint8_t
{
None = 0,
ByPerfAsc = 1,
ByPerfDesc = 2
};
//! @brief Starts a test case.
void startTestCase(const std::string& message, const Sort& sort_method = Sort::None)
{
m_test_case_message = message;
m_sort_method = sort_method;
}
//! @brief Ends a test case.
void endTestCase()
{
printResult();
m_units.clear();
}
//! @brief Starts a unit.
//! @see endUnit()
void startUnit(const std::string& name)
{
Unit unit(name);
unit.start();
m_units.push_back(unit);
}
//! @brief Ends a unit.
//! @see startUnit()
void endUnit()
{
if(!m_units.empty())
{
auto& last_unit = m_units.at(m_units.size() - 1);
if(!last_unit.isCompleted())
{
last_unit.end();
}
}
}
private:
class Unit
{
public:
Unit(const std::string& name) : m_name(name) {}
inline std::string getName() const noexcept { return m_name; }
inline double getResult() const noexcept { return m_result_ms; }
inline bool isRunning() const noexcept { return m_completed; }
inline bool isCompleted() const noexcept { return m_completed; }
void start()
{
if(m_completed || m_running) return;
m_running = true;
m_start = clock_t::now();
}
void end()
{
if(!m_running || m_completed) return;
m_end = clock_t::now();
duration_t time = (m_end - m_start);
m_result_ms = time.count() * 1000.;
m_completed = true;
m_running = false;
}
private:
std::string m_name;
timestamp_t m_start;
timestamp_t m_end;
bool m_running = false;
bool m_completed = false;
double m_result_ms;
};
class Print
{
public:
Print(const std::string& message) {std::cout << message;}
static void newLine() {std::cout << '\n';}
static void DashedLine_1()
{
for(int i = 0; i < 20; ++i)
{
std::cout << '-';
}
}
static void DashedLine()
{
for(int i = 0; i < 80; ++i)
{
std::cout << ((i % 2) ? '=' : '-');
}
}
};
void sortResult() noexcept
{
if(m_sort_method != Sort::None)
{
std::sort(m_units.begin(), m_units.end(), [&](const Unit& lhs, const Unit& rhs)
{
if(m_sort_method == Sort::ByPerfAsc)
{
return (lhs.getResult() < rhs.getResult());
}
else if(m_sort_method == Sort::ByPerfDesc)
{
return (lhs.getResult() > rhs.getResult());
}
return true;
});
}
}
void printResult()
{
sortResult();
Print::DashedLine();
Print::newLine();
std::cout << "Test : " << m_test_case_message;
Print::newLine();
Print::DashedLine_1();
Print::newLine();
double total = 0.;
for(auto& unit : m_units)
{
auto name = unit.getName();
double result = unit.getResult();
std::cout << "|" << result << " ms| \t=> " << name;
Print::newLine();
total += result;
}
Print::newLine();
std::cout << "Total : " << total << " ms";
Print::newLine();
Print::newLine();
}
std::vector<Unit> m_units;
Sort m_sort_method;
std::string m_test_case_message;
};
#endif /* KIWI_TEST_UTILITY_HPP_INCLUDED */
| 5,256
|
C++
|
.h
| 163
| 22.773006
| 91
| 0.5
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
754,642
|
Processors.h
|
Musicoll_Kiwi/Test/Dsp/Processors.h
|
/*
==============================================================================
This file is part of the KIWI library.
- Copyright (c) 2014-2016, Pierre Guillot & Eliott Paris.
- Copyright (c) 2016-2019, CICM, ANR MUSICOLL, Eliott Paris, Pierre Guillot, Jean Millot.
Permission is granted to use this software under the terms of the GPL v3
(or any later version). Details can be found at: www.gnu.org/licenses
KIWI is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more details.
------------------------------------------------------------------------------
Contact : cicm.mshparisnord@gmail.com
==============================================================================
*/
#pragma once
#include <KiwiDsp/KiwiDsp_Processor.h>
using namespace kiwi;
using namespace dsp;
// ==================================================================================== //
// PROCESSORS //
// ==================================================================================== //
// ==================================================================================== //
// SIG //
// ==================================================================================== //
class Sig : public Processor
{
public:
Sig(sample_t value) noexcept : Processor(0ul, 1ul), m_value(value) {}
~Sig() = default;
private:
void prepare(PrepareInfo const& infos) override final
{
setPerformCallBack(this, &Sig::perform);
}
void perform(Buffer const& /*input*/, Buffer& output)
{
output[0ul].fill(m_value);
}
sample_t m_value;
};
// ==================================================================================== //
// PLUS SCALAR //
// ==================================================================================== //
class PlusScalar : public Processor
{
public:
PlusScalar(sample_t value) noexcept : Processor(1ul, 1ul), m_value(value) {}
~PlusScalar() = default;
private:
void prepare(PrepareInfo const& infos) override final
{
m_sig_value.reset(new Signal(infos.vector_size, m_value));
setPerformCallBack(this, &PlusScalar::perform);
}
void perform(Buffer const& input, Buffer& output) noexcept
{
Signal::add(input[0ul], *m_sig_value.get(), output[0ul]);
}
sample_t m_value;
std::unique_ptr<const Signal> m_sig_value;
};
// ==================================================================================== //
// PLUS SIGNAL //
// ==================================================================================== //
class PlusSignal : public Processor
{
public:
PlusSignal() noexcept : Processor(2ul, 1ul) {}
~PlusSignal() noexcept{}
private:
void prepare(PrepareInfo const& infos) override final
{
setPerformCallBack(this, &PlusSignal::perform);
}
void perform(Buffer const& input, Buffer& output) noexcept
{
Signal::add(input[0ul], input[1ul], output[0ul]);
}
};
// ==================================================================================== //
// COPY THROW //
// ==================================================================================== //
class CopyThrow : public Processor
{
public:
CopyThrow() noexcept : Processor(1ul, 0ul) {}
~CopyThrow() noexcept{}
private:
void prepare(PrepareInfo const& infos) override final
{
if(infos.sample_rate != 44100ul || infos.vector_size != 64ul)
{
throw Error(std::string("CopyThrow wants a sample rate of 44100 and a vector size of 64."));
}
else
{
setPerformCallBack(this, &CopyThrow::perform);
}
}
void perform(Buffer const& input, Buffer& output) noexcept
{
output[0ul].add(input[0ul]);
output[0ul].add(input[1ul]);
}
};
// ==================================================================================== //
// PRINT //
// ==================================================================================== //
class Print : public Processor
{
public:
Print(std::string& string_to_write) noexcept : Processor(1ul, 0ul), m_string(string_to_write) {}
~Print() = default;
private:
void prepare(PrepareInfo const& infos) override final
{
setPerformCallBack(this, &Print::perform);
}
void perform(Buffer const& input, Buffer&) noexcept
{
Signal const& sig = input[0];
const size_t size = sig.size();
m_string.clear();
m_string.reserve(size*10);
m_string += "[";
if(size)
{
for(size_t i = 0; i < size - 1; ++i)
{
m_string += std::to_string(sig[i]) + ", ";
}
m_string += std::to_string(sig[size - 1]);
}
m_string += "]";
}
std::string& m_string;
};
// ==================================================================================== //
// COUNT //
// ==================================================================================== //
class Count : public Processor
{
public:
Count() noexcept : Processor(0ul, 1ul) {}
~Count() = default;
private:
void prepare(PrepareInfo const& infos) override final
{
setPerformCallBack(this, &Count::perform);
}
void perform(Buffer const&, Buffer& output) noexcept
{
Signal& sig = output[0ul];
sample_t* sig_data = sig.data();
size_t framesize = sig.size();
while(framesize--)
{
*sig_data++ = m_count++;
}
}
size_t m_count = 0ul;
};
// ==================================================================================== //
// NULLPROCESSOR //
// ==================================================================================== //
class NullProcessor : public Processor
{
public:
NullProcessor(size_t n_inlets, size_t n_outlets) noexcept : Processor(n_inlets, n_outlets) {}
NullProcessor() = default;
private:
void prepare(PrepareInfo const& infos) override final
{
setPerformCallBack(this, &NullProcessor::perform);
}
void perform(Buffer const&, Buffer& output) noexcept
{
}
};
// ==================================================================================== //
// REMOVER //
// ==================================================================================== //
class PlusScalarRemover : public Processor
{
public:
PlusScalarRemover() noexcept : Processor(2ul, 1ul) {}
~PlusScalarRemover() = default;
private:
void prepare(PrepareInfo const& info) override final
{
if (info.inputs[0])
{
setPerformCallBack(this, &PlusScalarRemover::perform);
}
};
void perform(Buffer const& input, Buffer& output) noexcept
{
Signal::add(input[0ul], input[1ul], output[0ul]);
}
};
// ==================================================================================== //
// SHARED SIGNAL //
// ==================================================================================== //
class SharedSignalsChecker : public Processor
{
public:
SharedSignalsChecker() noexcept : Processor(3ul, 3ul) {}
~SharedSignalsChecker() noexcept {}
Buffer const* m_input;
Buffer const* m_output;
private:
void prepare(PrepareInfo const& info) override final
{
setPerformCallBack(this, &SharedSignalsChecker::perform);
};
void perform(Buffer const& input, Buffer& output) noexcept
{
m_input = &input;
m_output = &output;
}
};
// ==================================================================================== //
// CONDITIONAL PERFORM //
// ==================================================================================== //
class CondPerform : public Processor
{
public:
CondPerform() noexcept : Processor(2, 1) {}
~CondPerform() = default;
private:
void perform1(Buffer const& input, Buffer& output) {output[0][0] = 1.; }
void perform2(Buffer const& input, Buffer& output){ output[0][0] = 2.; }
void perform0(Buffer const& input, Buffer& output){ output[0][0] = 0.; }
void prepare(PrepareInfo const& infos) override final
{
if (infos.inputs[0])
{
setPerformCallBack(this, &CondPerform::perform1);
}
else if(infos.inputs[1])
{
setPerformCallBack(this, &CondPerform::perform2);
}
else
{
setPerformCallBack(this, &CondPerform::perform0);
}
}
};
| 9,680
|
C++
|
.h
| 249
| 33.289157
| 104
| 0.428727
|
Musicoll/Kiwi
| 134
| 11
| 7
|
GPL-3.0
|
9/20/2024, 9:42:21 PM (Europe/Amsterdam)
| false
| false
| false
| false
| false
| false
| false
| false
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.