view audioio/ClipMixer.h @ 305:9716c75499ef tonioni

Toward using a sample mixer (with arbitrary frequency target) instead of dssi player plugin
author Chris Cannam
date Tue, 07 Jan 2014 10:58:10 +0000
parents
children 289d65722123
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */

/*
    Sonic Visualiser
    An audio file viewer and annotation editor.
    Centre for Digital Music, Queen Mary, University of London.
    This file copyright 2006 Chris Cannam, 2006-2014 QMUL.
    
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.  See the file
    COPYING included with this distribution for more information.
*/

#ifndef _CLIP_MIXER_H_
#define _CLIP_MIXER_H_

#include <QString>
#include <vector>

/**
 * Mix in synthetic notes produced by resampling a prerecorded
 * clip. That is, this is a sampler.
 */

class ClipMixer
{
public:
    ClipMixer(int channels, int sampleRate, int blockSize);
    ~ClipMixer();

    bool loadClipData(QString clipFilePath, float clipF0);

    //!!! what can we find in common with the NoteData type and
    //!!! AudioGenerator's NoteOff?

    struct NoteStart {
	int id; // unique to match note end
	int frameOffset; // in current processing block
	float frequency; // Hz
	float level; // volume in range (0,1]
	float pan; // range [-1,1]
    };

    struct NoteEnd {
	int id; // matching note start
	int frameOffset; // in current processing block
    };

    void mix(float **toBuffers, 
	     std::vector<NoteStart> newNotes, 
	     std::vector<NoteEnd> endingNotes);

private:
    int m_channels;
    int m_sampleRate;
    int m_blockSize;

    QString m_clipPath;

    float *m_clipData;
    int m_clipLength;
    float m_clipF0;
    float m_clipRate;
};


#endif