• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kunitoki / popsicle / 8195308623

07 Mar 2024 09:55PM UTC coverage: 20.126% (+1.3%) from 18.801%
8195308623

Pull #24

github

kunitoki
More pixel tests
Pull Request #24: More tests coverage

283 of 398 new or added lines in 6 files covered. (71.11%)

45 existing lines in 5 files now uncovered.

23757 of 118043 relevant lines covered (20.13%)

3617.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/modules/juce_python/bindings/ScriptJuceAudioUtilsBindings.h
1
/**
2
 * juce_python - Python bindings for the JUCE framework.
3
 *
4
 * This file is part of the popsicle project.
5
 *
6
 * Copyright (c) 2024 - kunitoki <kunitoki@gmail.com>
7
 *
8
 * popsicle is an open source library subject to commercial or open-source licensing.
9
 *
10
 * By using popsicle, you agree to the terms of the popsicle License Agreement, which can
11
 * be found at https://raw.githubusercontent.com/kunitoki/popsicle/master/LICENSE
12
 *
13
 * Or: You may also use this code under the terms of the GPL v3 (see www.gnu.org/licenses).
14
 *
15
 * POPSICLE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER EXPRESSED
16
 * OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE DISCLAIMED.
17
 */
18

19
#pragma once
20

21
#if !JUCE_MODULE_AVAILABLE_juce_audio_utils
22
 #error This binding file requires adding the juce_audio_utils module in the project
23
#else
24
 #include <juce_audio_utils/juce_audio_utils.h>
25
#endif
26

27
#include "ScriptJuceGuiBasicsBindings.h"
28
#include "ScriptJuceAudioBasicsBindings.h"
29

30
#define JUCE_PYTHON_INCLUDE_PYBIND11_OPERATORS
31
#define JUCE_PYTHON_INCLUDE_PYBIND11_STL
32
#include "../utilities/PyBind11Includes.h"
33

34
#include "../utilities/PythonInterop.h"
35

36
namespace popsicle::Bindings {
37

38
// =================================================================================================
39

40
void registerJuceAudioUtilsBindings (pybind11::module_& m);
41

42
// =================================================================================================
43

44
template <class Base = juce::AudioAppComponent>
45
struct PyAudioAppComponent : PyComponent<Base>
46
{
47
    using PyComponent<Base>::PyComponent;
48

49
    void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override
×
50
    {
51
        PYBIND11_OVERRIDE_PURE (void, Base, prepareToPlay, samplesPerBlockExpected, sampleRate);
×
52
    }
53

54
    void releaseResources() override
×
55
    {
56
        PYBIND11_OVERRIDE_PURE (void, Base, releaseResources);
×
57
    }
58

59
    void getNextAudioBlock (const juce::AudioSourceChannelInfo& bufferToFill) override
×
60
    {
61
        PYBIND11_OVERRIDE_PURE (void, Base, getNextAudioBlock, bufferToFill);
×
62
    }
63
};
64

65
// =================================================================================================
66

67
template <class Base = juce::AudioThumbnailBase>
68
struct PyAudioThumbnailBase : Base
69
{
70
    using Base::Base;
71

72
    void clear() override
×
73
    {
74
        PYBIND11_OVERRIDE_PURE (void, Base, clear);
×
75
    }
76

77
    bool setSource (juce::InputSource* newSource) override
×
78
    {
79
        PYBIND11_OVERRIDE_PURE (bool, Base, setSource, newSource);
×
80
    }
81

82
    void setReader (juce::AudioFormatReader* newReader, juce::int64 hashCode) override
×
83
    {
84
        PYBIND11_OVERRIDE_PURE (void, Base, setReader, newReader, hashCode);
×
85
    }
86

87
    bool loadFrom (juce::InputStream& input) override
×
88
    {
89
        PYBIND11_OVERRIDE_PURE (bool, Base, loadFrom, input);
×
90
    }
91

92
    void saveTo (juce::OutputStream& output) const override
×
93
    {
94
        PYBIND11_OVERRIDE_PURE (void, Base, saveTo, output);
×
95
    }
96

97
    int getNumChannels() const noexcept override
×
98
    {
99
        PYBIND11_OVERRIDE_PURE (int, Base, getNumChannels);
×
100
    }
101

102
    double getTotalLength() const noexcept override
×
103
    {
104
        PYBIND11_OVERRIDE_PURE (double, Base, getTotalLength);
×
105
    }
106

107
    void drawChannel (juce::Graphics& g,
×
108
                      const juce::Rectangle<int>& area,
109
                      double startTimeSeconds,
110
                      double endTimeSeconds,
111
                      int channelNum,
112
                      float verticalZoomFactor) override
113
    {
114
        pybind11::gil_scoped_acquire gil;
×
115

116
        if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawChannel"); override_)
×
117
        {
118
            override_ (std::addressof (g), area, startTimeSeconds, endTimeSeconds, channelNum, verticalZoomFactor);
×
119

120
            return;
×
121
        }
122

123
        pybind11::pybind11_fail("Tried to call pure virtual function \"AudioThumbnailBase::drawChannel\"");
×
124
    }
125

126
    void drawChannels (juce::Graphics& g,
×
127
                       const juce::Rectangle<int>& area,
128
                       double startTimeSeconds,
129
                       double endTimeSeconds,
130
                       float verticalZoomFactor) override
131
    {
132
        pybind11::gil_scoped_acquire gil;
×
133

134
        if (pybind11::function override_ = pybind11::get_override (static_cast<Base*> (this), "drawChannels"); override_)
×
135
        {
136
            override_ (std::addressof (g), area, startTimeSeconds, endTimeSeconds, verticalZoomFactor);
×
137

138
            return;
×
139
        }
140

141
        pybind11::pybind11_fail("Tried to call pure virtual function \"AudioThumbnailBase::drawChannels\"");
×
142
    }
143

144
    bool isFullyLoaded() const noexcept override
×
145
    {
146
        PYBIND11_OVERRIDE_PURE (bool, Base, isFullyLoaded);
×
147
    }
148

149
    juce::int64 getNumSamplesFinished() const noexcept override
×
150
    {
151
        PYBIND11_OVERRIDE_PURE (juce::int64, Base, getNumSamplesFinished);
×
152
    }
153

154
    float getApproximatePeak() const override
×
155
    {
156
        PYBIND11_OVERRIDE_PURE (float, Base, getApproximatePeak);
×
157
    }
158

159
    void getApproximateMinMax (double startTime, double endTime, int channelIndex,
×
160
                               float& minValue, float& maxValue) const noexcept override
161
    {
162
        pybind11::gil_scoped_acquire gil;
×
163

164
        if (pybind11::function override_ = pybind11::get_override (static_cast<const Base*> (this), "getApproximateMinMax"); override_)
×
165
        {
166
            auto results = override_ (startTime, endTime, channelIndex).cast<pybind11::tuple>();
×
167

168
            if (results.size() != 2)
×
169
                pybind11::pybind11_fail("Invalid return type of function \"AudioThumbnailBase::getApproximateMinMax\" must be tuple[float, 2]");
×
170

171
            minValue = results[0].cast<float>();
×
172
            maxValue = results[1].cast<float>();
×
173

174
            return;
×
175
        }
176

177
        pybind11::pybind11_fail("Tried to call pure virtual function \"AudioThumbnailBase::getApproximateMinMax\"");
×
178
    }
179

180
    juce::int64 getHashCode() const override
×
181
    {
182
        PYBIND11_OVERRIDE_PURE (juce::int64, Base, getHashCode);
×
183
    }
184

NEW
185
    void reset (int channels, double sampleRate, juce::int64 totalSamplesInSource) override
×
186
    {
NEW
187
        PYBIND11_OVERRIDE_PURE (void, Base, reset, channels, sampleRate, totalSamplesInSource);
×
188
    }
189

190
    void addBlock (juce::int64 sampleNumberInSource, const juce::AudioBuffer<float>& newData, int startOffsetInBuffer, int numSamples) override
×
191
    {
192
        PYBIND11_OVERRIDE_PURE (void, Base, addBlock, sampleNumberInSource, newData, startOffsetInBuffer, numSamples);
×
193
    }
194
};
195

196
} // namespace popsicle::Bindings
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc