Changeset fb615eb for examples


Ignore:
Timestamp:
Aug 14, 2005, 12:14:41 PM (19 years ago)
Author:
Paul Brossier <piem@altern.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
45345ee
Parents:
13d57e8
Message:

added pitch option to utils.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    r13d57e8 rfb615eb  
    5959smpl_t pitch               = 0.;
    6060aubio_pitchdetection_t * pitchdet;
    61 aubio_pitchdetection_type mode = aubio_pitch_yin; // aubio_pitch_mcomb
     61aubio_pitchdetection_type type_pitch = aubio_pitch_schmitt; // aubio_pitch_mcomb
     62aubio_pitchdetection_mode mode_pitch = aubio_pitchm_freq;
    6263uint_t median         = 6;
    6364
     
    8889        fprintf(stream, "usage: %s [ options ] \n", prog_name);
    8990        fprintf(stream,
    90                         "       -j      --jack          Use Jack.\n"
    91                         "       -o      --output        Output type.\n"
    92                         "       -i      --input         Input type.\n"
    93                         "       -h      --help          Display this message.\n"
    94                         "       -v      --verbose       Print verbose message.\n"
     91                        "       -h      --help          Display this message.\n"
     92                        "       -j      --jack          Use Jack.\n"
     93                        "       -o      --output        Output type.\n"
     94                        "       -i      --input         Input type.\n"
     95                        "       -O      --onset         Select onset detection algorithm.\n"
     96                        "       -t      --threshold     Set onset detection threshold.\n"
     97                        "       -s      --silence       Select silence threshold.\n"
     98                        "       -p      --pitch         Select pitch detection algorithm.\n"
     99                        "       -H      --hopsize       Set hopsize.\n"
     100                        "       -a      --averaging     Use averaging.\n"
    95101               );
    96102        exit(exit_code);
     
    98104
    99105int parse_args (int argc, char **argv) {
    100         const char *options = "hvjo:i:O:t:s:H:a";
     106        const char *options = "hvjo:i:O:t:s:p:H:a";
    101107        int next_option;
    102108        struct option long_options[] =
     
    110116                {"threshold", 1, NULL, 't'},
    111117                {"silence"  , 1, NULL, 's'},
     118                {"pitch"    , 1, NULL, 'p'},
    112119                {"averaging", 0, NULL, 'a'},
    113120                {"hopsize",   1, NULL, 'H'},
    114121                {NULL       , 0, NULL, 0}
    115122        };
    116         prog_name = argv[0];   
     123        prog_name = argv[0];
    117124        if( argc < 1 ) {
    118125                usage (stderr, 1);
     
    129136                                input_filename = optarg;
    130137                                break;
    131                         case 'h':       /* help */
     138                        case 'h': /* help */
    132139                                usage (stdout, 0);
    133140                                return -1;
    134                         case 'v':               /* verbose */
     141                        case 'v': /* verbose */
    135142                                verbose = 1;
    136143                                break;
    137                         case 'j':               /* verbose */
     144                        case 'j':
    138145                                usejack = 1;
    139146                                break;
     
    173180                                   */
    174181                                break;
     182                        case 'p':
     183                                if (strcmp(optarg,"mcomb") == 0)
     184                                        type_pitch = aubio_pitch_mcomb;
     185                                else if (strcmp(optarg,"yin") == 0)
     186                                        type_pitch = aubio_pitch_yin;
     187                                else if (strcmp(optarg,"schmitt") == 0)
     188                                        type_pitch = aubio_pitch_schmitt;
     189                                else if (strcmp(optarg,"fcomb") == 0)
     190                                        type_pitch = aubio_pitch_fcomb;
     191                                else {
     192                                        debug("could not get pitch type.\n");
     193                                        abort();
     194                                }
     195                                break;
    175196                        case 'a':
    176197                                averaging = 1;
     
    179200                                overlap_size = atoi(optarg);
    180201                                break;
    181                         case '?':       /* unknown options */
     202                        case '?': /* unknown options */
    182203                                usage(stderr, 1);
    183204                                break;
    184                         case -1:                /* done with options */
    185                                 break;
    186                         default:                /*something else unexpected */
     205                        case -1: /* done with options */
     206                                break;
     207                        default: /*something else unexpected */
    187208                                abort ();
    188209                }
     
    204225                        exit(1);
    205226                }
    206         }       
     227        }
    207228        return 0;
    208229}
     
    243264  if (usepitch) {
    244265    pitchdet = new_aubio_pitchdetection(buffer_size*4,
    245                     overlap_size, channels, samplerate, mode, aubio_pitchm_freq);
     266                    overlap_size, channels, samplerate, type_pitch, mode_pitch);
    246267 
    247268  if (median) {
Note: See TracChangeset for help on using the changeset viewer.