|
35 | 35 | #include <praat/fon/Sound_to_Harmonicity.h> |
36 | 36 | #include <praat/fon/Sound_to_Intensity.h> |
37 | 37 | #include <praat/fon/Sound_to_Pitch.h> |
| 38 | +#include <praat/fon/Sound_to_PointProcess.h> |
38 | 39 |
|
39 | 40 | #include <pybind11/numpy.h> |
40 | 41 | #include <pybind11/stl.h> |
@@ -181,11 +182,24 @@ PRAAT_ENUM_BINDING(ToHarmonicityMethod) { |
181 | 182 | make_implicitly_convertible_from_string(*this); |
182 | 183 | } |
183 | 184 |
|
| 185 | +enum Channel { |
| 186 | + LEFT = 1, |
| 187 | + RIGHT = 2 |
| 188 | +}; |
| 189 | + |
| 190 | +PRAAT_ENUM_BINDING(Channel) { |
| 191 | + value("LEFT", Channel::LEFT); |
| 192 | + value("RIGHT", Channel::RIGHT); |
| 193 | + |
| 194 | + make_implicitly_convertible_from_string(*this); |
| 195 | +} |
| 196 | + |
184 | 197 | PRAAT_CLASS_BINDING(Sound) { |
185 | 198 | addTimeFrameSampledMixin(*this); |
186 | 199 |
|
187 | 200 | NESTED_BINDINGS(ToPitchMethod, |
188 | | - ToHarmonicityMethod) |
| 201 | + ToHarmonicityMethod, |
| 202 | + Channel) |
189 | 203 |
|
190 | 204 | using signature_cast_placeholder::_; |
191 | 205 |
|
@@ -611,6 +625,60 @@ PRAAT_CLASS_BINDING(Sound) { |
611 | 625 | }, |
612 | 626 | "number_of_coefficients"_a = 12, "window_length"_a = 0.015, "time_step"_a = 0.005, "firstFilterFreqency"_a = 100.0, "distance_between_filters"_a = 100.0, "maximum_frequency"_a = std::nullopt); |
613 | 627 |
|
| 628 | + // FORM (NEW_Sound_to_PointProcess_extrema, U"Sound: To PointProcess |
| 629 | + // (extrema)", nullptr) |
| 630 | + def( |
| 631 | + "to_point_process_extrema", |
| 632 | + [](Sound self, Channel channel, bool includeMaxima, bool includeMinima, |
| 633 | + kVector_peakInterpolation peakInterpolationType) { |
| 634 | + int ch = static_cast<int>(channel); |
| 635 | + return Sound_to_PointProcess_extrema(self, ch > self->ny ? 1 : ch, |
| 636 | + peakInterpolationType, |
| 637 | + includeMaxima, includeMinima); |
| 638 | + }, |
| 639 | + "channel"_a = Channel::LEFT, "include_maxima"_a = true, "include_minima"_a = false, |
| 640 | + "interpolation"_a = kVector_peakInterpolation::SINC70); |
| 641 | + |
| 642 | + // FORM (NEW_Sound_to_PointProcess_periodic_cc, U"Sound: To PointProcess |
| 643 | + // (periodic, cc)", U"Sound: To PointProcess (periodic, cc)...") { |
| 644 | + def( |
| 645 | + "to_point_process_periodic", |
| 646 | + [](Sound self, float minimumPitch, float maximumPitch) { |
| 647 | + if (maximumPitch <= minimumPitch) |
| 648 | + Melder_throw( |
| 649 | + U"Your maximum pitch should be greater than your minimum pitch."); |
| 650 | + return Sound_to_PointProcess_periodic_cc(self, minimumPitch, |
| 651 | + maximumPitch); |
| 652 | + }, |
| 653 | + "minimum_pitch"_a = 75.0, "maximum_pitch"_a = 600.0); |
| 654 | + |
| 655 | + // FORM (NEW_Sound_to_PointProcess_periodic_peaks, U"Sound: To PointProcess |
| 656 | + // (periodic, peaks)", U"Sound: To PointProcess (periodic, peaks)...") { |
| 657 | + def( |
| 658 | + "to_point_process_periodic_peaks", |
| 659 | + [](Sound self, float minimumPitch, float maximumPitch, bool includeMaxima, |
| 660 | + bool includeMinima) { |
| 661 | + if (maximumPitch <= minimumPitch) |
| 662 | + Melder_throw( |
| 663 | + U"Your maximum pitch should be greater than your minimum pitch."); |
| 664 | + return Sound_to_PointProcess_periodic_peaks( |
| 665 | + self, minimumPitch, maximumPitch, includeMaxima, includeMinima); |
| 666 | + }, |
| 667 | + "minimum_pitch"_a = 75.0, "maximum_pitch"_a = 600.0, |
| 668 | + "include_maxima"_a = true, "include_minima"_a = false); |
| 669 | + |
| 670 | + // FORM (NEW_Sound_to_PointProcess_zeroes, U"Get zeroes", nullptr) { |
| 671 | + def( |
| 672 | + "to_point_process_zeros", |
| 673 | + [](Sound self, Channel ch, bool includeRaisers, bool includeFallers) { |
| 674 | + int channel = static_cast<int>(ch); |
| 675 | + return Sound_to_PointProcess_zeroes(self, |
| 676 | + channel > self->ny ? 1 : channel, |
| 677 | + includeRaisers, includeFallers); |
| 678 | + }, |
| 679 | + "channel"_a = Channel::LEFT, "include_raisers"_a = true, |
| 680 | + "include_fallers"_a = false); |
| 681 | + |
614 | 682 | // TODO For some reason praat_David_init.cpp also still contains Sound functionality |
615 | 683 | // TODO Still a bunch of Sound in praat_LPC_init.cpp |
616 | 684 | } |
|
0 commit comments