| 1 | #cxx . . $ `<file>/dwtools/Sound_extensions.h`/ifndef _Sound_extensions_h_ |
| 2 | #define _Sound_extensions_h_cxx . . $ `dwtools/Sound_extensions.h:2:9`! |
| 3 | /* Sound_extensions.h |
| 4 | * |
| 5 | * Copyright (C) 1993-2022 David Weenink |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "Sound.h"cxx . . $ `<file>/fon/Sound.h`/ |
| 22 | #include "Pitch.h"cxx . . $ `<file>/fon/Pitch.h`/ |
| 23 | #include "Collection.h"cxx . . $ `<file>/sys/Collection.h`/ |
| 24 | #include "PointProcess.h"cxx . . $ `<file>/fon/PointProcess.h`/ |
| 25 | #include "TextGrid.h"cxx . . $ `<file>/fon/TextGrid.h`/ |
| 26 | #include "Sound_extensions_enums.h"cxx . . $ `<file>/dwtools/Sound_extensions_enums.h`/ |
| 27 | |
| 28 | Thing_declarecxx . . $ `sys/Thing.h:51:9`! (Interpreter); |
| 29 | |
| 30 | int Sound_writeToNistAudioFilecxx . . $ Sound_writeToNistAudioFile(30bb4f2afe087565). (Soundcxx . . $ Sound# me, MelderFilecxx . . $ MelderFile# file); |
| 31 | |
| 32 | void Sound_saveAsMP3File_VBRcxx . . $ Sound_saveAsMP3File_VBR(8c2c82338f071e5f). (Soundcxx . . $ Sound# me, MelderFilecxx . . $ MelderFile# file, double inverseQuality); |
| 33 | /* |
| 34 | 0 <= inverseQuality < 10 |
| 35 | 0 is highest quality, 9.99 is lowest quality |
| 36 | */ |
| 37 | |
| 38 | autoSoundcxx . . $ autoSound# Sound_readFromCmuAudioFilecxx . . $ Sound_readFromCmuAudioFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file); |
| 39 | |
| 40 | /* only 16 bit signed has been tested !! */ |
| 41 | autoSoundcxx . . $ autoSound# Sound_readFromRawFilecxx . . $ Sound_readFromRawFile(878ee707841ba021). (MelderFilecxx . . $ MelderFile# file, const char *format, int nBitsCoding, |
| 42 | bool littleEndian, bool unSigned, integercxx . . $ integer# skipNBytes, double samplingFrequency); |
| 43 | /* Reads a Sound from a raw file: |
| 44 | * fileName : name of the file |
| 45 | * format : "integer" (default) |
| 46 | * "float" (this implies nBitsCoding=nBitsStorage=32, see below) |
| 47 | * nBitsCoding : number of bits used in the coding (1..16) (default = 16 ) |
| 48 | * (the storage is assumed to be a multiple of 8 bits ) |
| 49 | * littleEndian: if littleEndian != 0 then little-endian else big-endian |
| 50 | * unSigned : if unSigned != 0 then unsigned else signed |
| 51 | * skipNBytes : start reading after this number of bytes (skipNBytes >= 0 ) |
| 52 | */ |
| 53 | |
| 54 | autoSoundcxx . . $ autoSound# Sound_readFromDialogicADPCMFilecxx . . $ Sound_readFromDialogicADPCMFile(8bbb6f10a28ca5d0). (MelderFilecxx . . $ MelderFile# file, double sampleRate); |
| 55 | /* |
| 56 | */ |
| 57 | |
| 58 | autoSoundcxx . . $ autoSound# Sound_readFromOggVorbisFilecxx . . $ Sound_readFromOggVorbisFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file); |
| 59 | autoSoundcxx . . $ autoSound# Sound_readFromOggOpusFilecxx . . $ Sound_readFromOggOpusFile(93fb99dfd38ebabb). (MelderFilecxx . . $ MelderFile# file); |
| 60 | |
| 61 | void Sound_into_Soundcxx . . $ Sound_into_Sound(9b5e4c6d6787168f). (Soundcxx . . $ Sound# me, Soundcxx . . $ Sound# to, double startTime); |
| 62 | /* precondition: my dx == to->dx (equal sampling times */ |
| 63 | |
| 64 | void Sound_overwritePartcxx . . $ Sound_overwritePart(54573cefd6e9b066). (Soundcxx . . $ Sound# me, double t1, double t2, Soundcxx . . $ Sound# thee, double t3); |
| 65 | /* |
| 66 | Overwrite the part between (t1,t2) in me with samples from Sound thee, |
| 67 | starting at t3 in thee. |
| 68 | */ |
| 69 | |
| 70 | autoSoundcxx . . $ autoSound# Sound_derivativecxx . . $ Sound_derivative(14181e1c5f839e03). (Soundcxx . . $ Sound# me, double lowPassFrequency, double smoothing, double peakAmplitude); |
| 71 | /* |
| 72 | The real derivative |
| 73 | */ |
| 74 | |
| 75 | autoSoundcxx . . $ autoSound# Sound_createGaussiancxx . . $ Sound_createGaussian(c2815364717639a8). (double windowDuration, double samplingFrequency); |
| 76 | |
| 77 | autoSoundcxx . . $ autoSound# Sound_createHammingcxx . . $ Sound_createHamming(c2815364717639a8). (double windowDuration, double samplingFrequency); |
| 78 | |
| 79 | autoSoundcxx . . $ autoSound# Sound_createSimpleToneComplexcxx . . $ Sound_createSimpleToneComplex(27b39459d2e92940). (double minimumTime, double maximumTime, double samplingFrequency, |
| 80 | double firstFrequency, integercxx . . $ integer# numberOfComponents, double frequencyDistance, bool scaleAmplitudes); |
| 81 | |
| 82 | autoSoundcxx . . $ autoSound# Sound_createMistunedHarmonicComplexcxx . . $ Sound_createMistunedHarmonicComplex(102b95afd45f1806). (double minimumTime, double maximumTime, double samplingFrequency, |
| 83 | double firstFrequency, integercxx . . $ integer# numberOfComponents, integercxx . . $ integer# mistunedComponent, double mistuningFraction, bool scaleAmplitudes); |
| 84 | |
| 85 | autoSoundcxx . . $ autoSound# Sound_createGammaTonecxx . . $ Sound_createGammaTone(9a0130e8aee7eee5). (double minimumTime, double maximumTime, double samplingFrequency, |
| 86 | double gamma, double frequency, double bandwidth, double initialPhase, double addition, bool scaleAmplitudes); |
| 87 | |
| 88 | autoSoundcxx . . $ autoSound# Sound_createShepardTonecxx . . $ Sound_createShepardTone(50f3797e83c6f1f9). (double minimumTime, double maximumTime, double samplingFrequency, |
| 89 | double lowestFrequency, integercxx . . $ integer# numberOfComponents, double frequencyChange, double amplitudeRange); |
| 90 | |
| 91 | autoSoundcxx . . $ autoSound# Sound_createShepardToneComplexcxx . . $ Sound_createShepardToneComplex(512a3d70a55368dc). (double minimumTime, double maximumTime, |
| 92 | double samplingFrequency, double lowestFrequency, integercxx . . $ integer# numberOfComponents, |
| 93 | double frequencyChange_st, double amplitudeRange, double octaveShiftFraction); |
| 94 | |
| 95 | autoSoundcxx . . $ autoSound# Sound_createPattersonWightmanTonecxx . . $ Sound_createPattersonWightmanTone(22be15b3d7dc2297). (double minimumTime, double maximumTime, double samplingFrequency, |
| 96 | double baseFrequency, double frequencyShiftRatio, integercxx . . $ integer# numberOfComponents); |
| 97 | |
| 98 | autoSoundcxx . . $ autoSound# Sound_createPlompTonecxx . . $ Sound_createPlompTone(22be15b3d7dc2297). (double minimumTime, double maximumTime, double samplingFrequency, |
| 99 | double baseFrequency, double frequencyFraction, integercxx . . $ integer# m); |
| 100 | |
| 101 | autoSoundcxx . . $ autoSound# Sound_createFromWindowFunctioncxx . . $ Sound_createFromWindowFunction(2c6fa2fda23b78ff). (double effectiveTime, double samplingFrequency, int windowType); |
| 102 | /* 1; rect 2:hamming 3: bartlet 4: welch 5: hanning 6:gaussian */ |
| 103 | |
| 104 | autoSoundcxx . . $ autoSound# Sound_filterByGammaToneFilter4cxx . . $ Sound_filterByGammaToneFilter4(ea4a901bd2d942eb). (Soundcxx . . $ Sound# me, double centre_frequency, double bandwidth); |
| 105 | |
| 106 | autoSoundcxx . . $ autoSound# Sound_filterByGammaToneFiltercxx . . $ Sound_filterByGammaToneFilter(7aaec93b6b5f00a7). (Soundcxx . . $ Sound# me, double centre_frequency, double bandwidth, double gamma, double initialPhase); |
| 107 | |
| 108 | void Sounds_multiplycxx . . $ Sounds_multiply(3740d3b02ef916dc). (Soundcxx . . $ Sound# me, Soundcxx . . $ Sound# thee); |
| 109 | /* precondition: my nx == thy nx */ |
| 110 | |
| 111 | double Sound_correlatePartscxx . . $ Sound_correlateParts(fb20d80074545761). (Soundcxx . . $ Sound# me, double t1, double t2, double duration); |
| 112 | /* |
| 113 | Correlate part (t1, t1+duration) with (t2, t2+duration) |
| 114 | */ |
| 115 | |
| 116 | double Sound_localPeakcxx . . $ Sound_localPeak(fb20d80074545761). (Soundcxx . . $ Sound# me, double fromTime, double toTime, double reference); |
| 117 | |
| 118 | autoSoundcxx . . $ autoSound# Sound_localAveragecxx . . $ Sound_localAverage(7d5b0f4d4f1057c1). (Soundcxx . . $ Sound# me, double averaginginterval, int windowType); |
| 119 | /* y [n] = sum(i=-n, i=n, x [n+i]) / (2*n+1) */ |
| 120 | |
| 121 | double Sound_powercxx . . $ Sound_power(152928a1b0c69725). (Soundcxx . . $ Sound# me); |
| 122 | |
| 123 | void Sound_scale_dBcxx . . $ Sound_scale_dB(e59d264236af2337). (Soundcxx . . $ Sound# me, double level_dB); |
| 124 | /* |
| 125 | Scales the amplitude of a Sound to a certain dB level. |
| 126 | The reference value is an amplitude of 1. |
| 127 | All amplitudes are multiplied by a scale factor which is |
| 128 | 10^(level_dB/10) / extremum, |
| 129 | where extremum is the maximum of the absolute values the signal values. |
| 130 | */ |
| 131 | |
| 132 | void Sound_fadecxx . . $ Sound_fade(3d2526c498c6aff2). (Soundcxx . . $ Sound# me, int channel, double t, double fadeTime, bool fadeOut, bool fadeGlobal); |
| 133 | /* if !fadeOut fade in with (1-cos)/2 else fade out with (1+cos)/2 |
| 134 | channel = 0 (all). |
| 135 | */ |
| 136 | |
| 137 | void Sound_draw_btlrcxx . . $ Sound_draw_btlr(795e12f324b9f7ba). (Soundcxx . . $ Sound# me, Graphicscxx . . $ Graphics# g, double tmin, double tmax, double amin, double amax, kSoundDrawingDirectioncxx . . $ kSoundDrawingDirection# drawingDirection, bool garnish); |
| 138 | /* direction is one of the macros's FROM_LEFT_TO_RIGHT... */ |
| 139 | |
| 140 | void Sound_drawWherecxx . . $ Sound_drawWhere(9778b5fe5cc92b1c). (Soundcxx . . $ Sound# me, Graphicscxx . . $ Graphics# g, double tmin, double tmax, double minimum, double maximum, |
| 141 | bool garnish, conststring32cxx . . $ conststring32# method, integercxx . . $ integer# numberOfBisections, conststring32cxx . . $ conststring32# formula, Interpretercxx . . $ Interpreter# interpreter); |
| 142 | |
| 143 | void Sound_paintWherecxx . . $ Sound_paintWhere(afda9ae9605827). (Soundcxx . . $ Sound# me, Graphicscxx . . $ Graphics# g, MelderColourcxx . . $ MelderColour# colour, double tmin, double tmax, |
| 144 | double minimum, double maximum, double level, bool garnish, |
| 145 | integercxx . . $ integer# numberOfBisections, conststring32cxx . . $ conststring32# formula, Interpretercxx . . $ Interpreter# interpreter |
| 146 | ); |
| 147 | |
| 148 | void Sounds_paintEnclosedcxx . . $ Sounds_paintEnclosed(e13f134447cd145b). (Soundcxx . . $ Sound# me, Soundcxx . . $ Sound# thee, Graphicscxx . . $ Graphics# g, MelderColourcxx . . $ MelderColour# colour, double tmin, double tmax, |
| 149 | double minimum, double maximum, bool garnish); |
| 150 | |
| 151 | autoSoundcxx . . $ autoSound# Sound_changeGendercxx . . $ Sound_changeGender(b8d61364458673d). (Soundcxx . . $ Sound# me, double pitchMin, double pitchMax, double pitchRatio, double formantFrequenciesRatio, double durationRatio); |
| 152 | |
| 153 | autoSoundcxx . . $ autoSound# Sound_Pitch_changeGendercxx . . $ Sound_Pitch_changeGender(590498e76b2ac70d). (Soundcxx . . $ Sound# me, Pitchcxx . . $ Pitch# him, double pitchRatio, double formantFrequenciesRatio, double durationRatio); |
| 154 | |
| 155 | autoSoundcxx . . $ autoSound# Sound_changeGender_oldcxx . . $ Sound_changeGender_old(e716600543947daf). (Soundcxx . . $ Sound# me, double fmin, double fmax, double formantRatio, double new_pitch, double pitchRangeFactor, double durationFactor); |
| 156 | |
| 157 | autoSoundcxx . . $ autoSound# Sound_Pitch_changeGender_oldcxx . . $ Sound_Pitch_changeGender_old(d071f5fe079739eb). (Soundcxx . . $ Sound# me, Pitchcxx . . $ Pitch# him, double formantRatio, double new_pitch, double pitchRangeFactor, double durationFactor); |
| 158 | |
| 159 | autoPointProcesscxx . . $ autoPointProcess# Sound_to_PointProcess_getJumpscxx . . $ Sound_to_PointProcess_getJumps(acf46c98b622c219). (Soundcxx . . $ Sound# me, integercxx . . $ integer# channel, double minimumJump, double maximumDuration); |
| 160 | /* |
| 161 | Marks jumps in the signal where the amplitude changes more than 'minimumJump' |
| 162 | within a time interval of maximumDuration |
| 163 | */ |
| 164 | |
| 165 | autoSoundcxx . . $ autoSound# Sound_changeSpeakercxx . . $ Sound_changeSpeaker(e716600543947daf). (Soundcxx . . $ Sound# me, double pitchMin, double pitchMax, |
| 166 | double formantMultiplier, // > 0 |
| 167 | double pitchMultiplier, // > 0 |
| 168 | double pitchRangeMultiplier, // any number |
| 169 | double durationMultiplier // > 0 |
| 170 | ); |
| 171 | |
| 172 | autoSoundcxx . . $ autoSound# Sound_Pitch_changeSpeakercxx . . $ Sound_Pitch_changeSpeaker(d071f5fe079739eb). (Soundcxx . . $ Sound# me, Pitchcxx . . $ Pitch# him, |
| 173 | double formantMultiplier, // > 0 |
| 174 | double pitchMultiplier, // > 0 |
| 175 | double pitchRangeMultiplier, // any number |
| 176 | double durationMultiplier // > 0 |
| 177 | ); |
| 178 | |
| 179 | /* Outphased */ |
| 180 | autoSoundcxx . . $ autoSound# Sound_changeGender_oldcxx . . $ Sound_changeGender_old(e716600543947daf). (Soundcxx . . $ Sound# me, double fmin, double fmax, double formantRatio, |
| 181 | double new_pitch, double pitchRangeFactor, double durationFactor); |
| 182 | |
| 183 | void Sound_getStartAndEndTimesOfSoundingcxx . . $ Sound_getStartAndEndTimesOfSounding(9f4b5a0510f32bd1). (Soundcxx . . $ Sound# me, double minPitch, double timeStep, |
| 184 | double silenceThreshold, double minSilenceDuration, double minSoundingDuration, double *out_t1, double *out_t2); |
| 185 | |
| 186 | autoSoundcxx . . $ autoSound# Sound_IntervalTier_cutPartsMatchingLabelcxx . . $ Sound_IntervalTier_cutPartsMatchingLabel(118e1fc044dbbb54). (Soundcxx . . $ Sound# me, IntervalTiercxx . . $ IntervalTier# thee, conststring32cxx . . $ conststring32# match); |
| 187 | /* Cut intervals that match the label from the sound. The starting time of the new sound is |
| 188 | * (1) my xmin if the first interval is not matching |
| 189 | * (2) the end time of the first interval if matching |
| 190 | */ |
| 191 | |
| 192 | autoSoundcxx . . $ autoSound# Sound_trimSilencesAtStartAndEndcxx . . $ Sound_trimSilencesAtStartAndEnd(5f1135d1e5f18dd8). (Soundcxx . . $ Sound# me, double trimDuration, double minPitch, double timeStep, double silenceThreshold, |
| 193 | double minSilenceDuration, double minSoundingDuration, double *startTimeOfSounding, double *endTimeOfSounding); |
| 194 | |
| 195 | autoSoundcxx . . $ autoSound# Sound_trimSilencescxx . . $ Sound_trimSilences(14f217b17a476bd). (Soundcxx . . $ Sound# me, double trimDuration, bool onlyAtStartAndEnd, double minPitch, double timeStep, |
| 196 | double silenceThreshold, double minSilenceDuration, double minSoundingDuration, autoTextGridcxx . . $ autoTextGrid# *tg, conststring32cxx . . $ conststring32# trimLabel); |
| 197 | |
| 198 | autoSoundcxx . . $ autoSound# Sound_removeNoisecxx . . $ Sound_removeNoise(249c8f6676cb4d2e). (Soundcxx . . $ Sound# me, double noiseStart, double noiseEnd, double windowLength, double minBandFilterFrequency, double maxBandFilterFrequency, double smoothing, kSoundNoiseReductionMethodcxx . . $ kSoundNoiseReductionMethod# method); |
| 199 | |
| 200 | autoSoundcxx . . $ autoSound# Sound_reduceNoisecxx . . $ Sound_reduceNoise(469627c0eacdcef5). (Soundcxx . . $ Sound# me, double noiseStart, double noiseEnd, double windowLength, double minBandFilterFrequency, double maxBandFilterFrequency, double smoothing, double noiseReduction_dB, kSoundNoiseReductionMethodcxx . . $ kSoundNoiseReductionMethod# method); |
| 201 | |
| 202 | void Sound_playAsFrequencyShiftedcxx . . $ Sound_playAsFrequencyShifted(e8681586079a5661). (Soundcxx . . $ Sound# me, double shiftBy, double newSamplingFrequency, integercxx . . $ integer# precision); |
| 203 | |
| 204 | /**** the following functions belongs to a numeric library. However there is an unwanted dependency on fon/Sound_enums.h */ |
| 205 | |
| 206 | void windowShape_into_VECcxx . . $ windowShape_into_VEC(1bbc8fdbd7847e3). (kSound_windowShapecxx . . $ kSound_windowShape# windowShape, VECcxx . . $ VEC# inout_window); |
| 207 | |
| 208 | autoSoundcxx . . $ autoSound# Sound_resampleAndOrPreemphasizecxx . . $ Sound_resampleAndOrPreemphasize(50b0edb6f91cc1e7). (constSoundcxx . . $ constSound# me, double maximumFrequency, integercxx . . $ integer# depth, double preEmphasisFrequency); |
| 209 | |
| 210 | #endif /* _Sound_extensions_h_ */ |