Changeset 4ed4b1f for src


Ignore:
Timestamp:
Feb 23, 2014, 5:07:57 PM (10 years ago)
Author:
Paul Brossier <piem@piem.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:
2eccf22
Parents:
c21553d
Message:

src/io/sink.h: add do_multi, preset_samplerate, preset_channels, get_samplerate, and get_channels

Location:
src/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/io/sink.c

    rc21553d r4ed4b1f  
    11/*
    2   Copyright (C) 2012 Paul Brossier <piem@aubio.org>
     2  Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org>
    33
    44  This file is part of aubio.
     
    2222#include "aubio_priv.h"
    2323#include "fvec.h"
     24#include "fmat.h"
    2425#include "io/sink.h"
    2526#ifdef __APPLE__
     
    3435
    3536typedef void (*aubio_sink_do_t)(aubio_sink_t * s, fvec_t * data, uint_t write);
    36 #if 0
    37 typedef void (*aubio_sink_do_multi_t)(aubio_sink_t * s, fmat_t * data, uint_t * read);
     37typedef void (*aubio_sink_do_multi_t)(aubio_sink_t * s, fmat_t * data, uint_t write);
     38typedef uint_t (*aubio_sink_preset_samplerate_t)(aubio_sink_t * s, uint_t samplerate);
     39typedef uint_t (*aubio_sink_preset_channels_t)(aubio_sink_t * s, uint_t channels);
    3840typedef uint_t (*aubio_sink_get_samplerate_t)(aubio_sink_t * s);
    3941typedef uint_t (*aubio_sink_get_channels_t)(aubio_sink_t * s);
    40 #endif
    4142typedef uint_t (*aubio_sink_close_t)(aubio_sink_t * s);
    4243typedef void (*del_aubio_sink_t)(aubio_sink_t * s);
     
    4546  void *sink;
    4647  aubio_sink_do_t s_do;
    47 #if 0
    4848  aubio_sink_do_multi_t s_do_multi;
     49  aubio_sink_preset_samplerate_t s_preset_samplerate;
     50  aubio_sink_preset_channels_t s_preset_channels;
    4951  aubio_sink_get_samplerate_t s_get_samplerate;
    5052  aubio_sink_get_channels_t s_get_channels;
    51 #endif
    5253  aubio_sink_close_t s_close;
    5354  del_aubio_sink_t s_del;
     
    6061  if (s->sink) {
    6162    s->s_do = (aubio_sink_do_t)(aubio_sink_apple_audio_do);
     63    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_apple_audio_do_multi);
     64    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_apple_audio_preset_samplerate);
     65    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_apple_audio_preset_channels);
     66    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_apple_audio_get_samplerate);
     67    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_apple_audio_get_channels);
    6268    s->s_close = (aubio_sink_close_t)(aubio_sink_apple_audio_close);
    6369    s->s_del = (del_aubio_sink_t)(del_aubio_sink_apple_audio);
     
    6975  if (s->sink) {
    7076    s->s_do = (aubio_sink_do_t)(aubio_sink_sndfile_do);
     77    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_sndfile_do_multi);
     78    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_sndfile_preset_samplerate);
     79    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_sndfile_preset_channels);
     80    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_sndfile_get_samplerate);
     81    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_sndfile_get_channels);
    7182    s->s_close = (aubio_sink_close_t)(aubio_sink_sndfile_close);
    7283    s->s_del = (del_aubio_sink_t)(del_aubio_sink_sndfile);
     
    7889  if (s->sink) {
    7990    s->s_do = (aubio_sink_do_t)(aubio_sink_wavwrite_do);
     91    s->s_do_multi = (aubio_sink_do_multi_t)(aubio_sink_wavwrite_do_multi);
     92    s->s_preset_samplerate = (aubio_sink_preset_samplerate_t)(aubio_sink_wavwrite_preset_samplerate);
     93    s->s_preset_channels = (aubio_sink_preset_channels_t)(aubio_sink_wavwrite_preset_channels);
     94    s->s_get_samplerate = (aubio_sink_get_samplerate_t)(aubio_sink_wavwrite_get_samplerate);
     95    s->s_get_channels = (aubio_sink_get_channels_t)(aubio_sink_wavwrite_get_channels);
    8096    s->s_close = (aubio_sink_close_t)(aubio_sink_wavwrite_close);
    8197    s->s_del = (del_aubio_sink_t)(del_aubio_sink_wavwrite);
     
    93109}
    94110
     111void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write) {
     112  s->s_do_multi((void *)s->sink, write_data, write);
     113}
     114
     115uint_t aubio_sink_preset_samplerate(aubio_sink_t * s, uint_t samplerate) {
     116  return s->s_preset_samplerate((void *)s->sink, samplerate);
     117}
     118
     119uint_t aubio_sink_preset_channels(aubio_sink_t * s, uint_t channels) {
     120  return s->s_preset_channels((void *)s->sink, channels);
     121}
     122
     123uint_t aubio_sink_get_samplerate(aubio_sink_t * s) {
     124  return s->s_get_samplerate((void *)s->sink);
     125}
     126
     127uint_t aubio_sink_get_channels(aubio_sink_t * s) {
     128  return s->s_get_channels((void *)s->sink);
     129}
     130
    95131uint_t aubio_sink_close(aubio_sink_t *s) {
    96132  return s->s_close((void *)s->sink);
  • src/io/sink.h

    rc21553d r4ed4b1f  
    11/*
    2   Copyright (C) 2012-2013 Paul Brossier <piem@aubio.org>
     2  Copyright (C) 2012-2014 Paul Brossier <piem@aubio.org>
    33
    44  This file is part of aubio.
     
    2626  Media sink to write blocks of consecutive audio samples to file.
    2727
     28  To read from file, use ::aubio_source_t.
     29
    2830  \example io/test-sink.c
    2931
     
    4850  Creates a new sink object.
    4951
     52  If samplerate is set to 0, the creation of the file will be delayed until
     53  both ::aubio_sink_preset_samplerate and ::aubio_sink_preset_channels have
     54  been called.
     55
    5056*/
    5157aubio_sink_t * new_aubio_sink(char_t * uri, uint_t samplerate);
     58
     59/**
     60
     61  preset sink samplerate
     62
     63  \param s sink, created with ::new_aubio_sink
     64  \param samplerate samplerate to preset the sink to, in Hz
     65
     66  \return 0 on success, 1 on error
     67
     68  Preset the samplerate of the sink. The file should have been created using a
     69  samplerate of 0.
     70
     71  The file will be opened only when both samplerate and channels have been set.
     72
     73*/
     74uint_t aubio_sink_preset_samplerate(aubio_sink_t *s, uint_t samplerate);
     75
     76/**
     77
     78  preset sink channels
     79
     80  \param s sink, created with ::new_aubio_sink
     81  \param channels number of channels to preset the sink to
     82
     83  \return 0 on success, 1 on error
     84
     85  Preset the samplerate of the sink. The file should have been created using a
     86  samplerate of 0.
     87
     88  The file will be opened only when both samplerate and channels have been set.
     89
     90*/
     91uint_t aubio_sink_preset_channels(aubio_sink_t *s, uint_t channels);
     92
     93/**
     94
     95  get samplerate of sink object
     96
     97  \param s sink object, created with ::new_aubio_sink
     98  \return samplerate, in Hz
     99
     100*/
     101uint_t aubio_sink_get_samplerate(aubio_sink_t *s);
     102
     103/**
     104
     105  get channels of sink object
     106
     107  \param s sink object, created with ::new_aubio_sink
     108  \return number of channels
     109
     110*/
     111uint_t aubio_sink_get_channels(aubio_sink_t *s);
    52112
    53113/**
     
    61121*/
    62122void aubio_sink_do(aubio_sink_t * s, fvec_t * write_data, uint_t write);
     123
     124/**
     125
     126  write polyphonic vector of length hop_size to sink
     127
     128  \param s sink, created with ::new_aubio_sink
     129  \param write_data ::fmat_t samples to write to sink
     130  \param write number of frames to write
     131
     132*/
     133void aubio_sink_do_multi(aubio_sink_t * s, fmat_t * write_data, uint_t write);
    63134
    64135/**
Note: See TracChangeset for help on using the changeset viewer.