2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
SampleFormat.h
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_SAMPLE_FORMAT__
|
|
|
|
#define __AUDACITY_SAMPLE_FORMAT__
|
|
|
|
|
|
|
|
#include "Audacity.h"
|
|
|
|
#include <wx/defs.h>
|
|
|
|
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
#include "audacity/Types.h"
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
//
|
|
|
|
// Definitions / Meta-Information
|
|
|
|
//
|
|
|
|
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
#if 0
|
|
|
|
// Moved to audacity/types.h
|
2010-01-23 19:44:49 +00:00
|
|
|
typedef enum {
|
|
|
|
int16Sample = 0x00020001,
|
|
|
|
int24Sample = 0x00040001,
|
|
|
|
floatSample = 0x0004000F
|
|
|
|
} sampleFormat;
|
|
|
|
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
/** \brief Return the size (in memory) of one sample (bytes) */
|
2016-09-06 11:40:49 +00:00
|
|
|
#define SAMPLE_SIZE(SampleFormat) ( size_t{ (SampleFormat) >> 16 } )
|
The fabled realtime effects...
I've made it where you can enable and disable via experimentals:
EXPERIMENTAL_REALTIME_EFFECTS
EXPERIMENTAL_EFFECTS_RACK
You will notice that, as of now, the only effects currently set up for
realtime are VSTs. Now that this is in, I will start converting the
rest.
As I start to convert the effects, the astute of you may notice that
they no longer directly access tracks or any "internal" Audacity
objects. This isolates the effects from changes in Audacity and makes
it much easier to add new ones.
Anyway, all 3 platforms can now display VST effects in graphical mode.
Yes, that means Linux too. There are quite a few VSTs for Linux if
you search for them.
The so-called "rack" definitely needs some discussion, work, and attention
from someone much better at graphics than me. I'm not really sure it should
stay in as-is. I'd originally planned for it to be simply a utility window
where you can store your (preconfigured) favorite effects. It should probably
revert back to that idea.
You may notice that this DOES include the API work I did. The realtime effects
were too tied to it and I didn't want to redo the whole thing. As I mentioned
elsewhere, the API stuff may or may not be very future proof.
So, let the critter complaints commence. I absolute KNOW there will be some.
(I know I'll be hearing from the Linux peeps pretty darn quickly. ;-))
2014-10-26 03:24:10 +00:00
|
|
|
#endif
|
|
|
|
|
2012-03-25 16:19:08 +00:00
|
|
|
// Used to determine how to fill in empty areas of audio.
|
|
|
|
typedef enum {
|
|
|
|
fillZero = 0,
|
|
|
|
fillTwo = 2
|
|
|
|
}fillFormat;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
/** \brief Return the size on disk of one uncompressed sample (bytes) */
|
2016-09-06 11:40:49 +00:00
|
|
|
#define SAMPLE_SIZE_DISK(SampleFormat) (((SampleFormat) == int24Sample) ? \
|
|
|
|
size_t{ 3 } : SAMPLE_SIZE(SampleFormat) )
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
const wxChar *GetSampleFormatStr(sampleFormat format);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Allocating/Freeing Samples
|
|
|
|
//
|
|
|
|
|
|
|
|
AUDACITY_DLL_API samplePtr NewSamples(int count, sampleFormat format);
|
|
|
|
AUDACITY_DLL_API void DeleteSamples(samplePtr p);
|
|
|
|
|
2015-03-28 18:46:40 +00:00
|
|
|
// RAII version of above
|
|
|
|
class SampleBuffer {
|
|
|
|
|
|
|
|
public:
|
|
|
|
SampleBuffer()
|
2016-02-01 15:16:00 +00:00
|
|
|
: mPtr(0)
|
2015-03-28 18:46:40 +00:00
|
|
|
{}
|
|
|
|
SampleBuffer(int count, sampleFormat format)
|
2016-02-01 15:16:00 +00:00
|
|
|
: mPtr(NewSamples(count, format))
|
2015-03-28 18:46:40 +00:00
|
|
|
{}
|
|
|
|
~SampleBuffer()
|
|
|
|
{
|
|
|
|
Free();
|
|
|
|
}
|
|
|
|
|
|
|
|
// WARNING! May not preserve contents.
|
2016-02-01 15:16:00 +00:00
|
|
|
SampleBuffer &Allocate(int count, sampleFormat format)
|
2015-03-28 18:46:40 +00:00
|
|
|
{
|
2016-02-01 15:16:00 +00:00
|
|
|
Free();
|
|
|
|
mPtr = NewSamples(count, format);
|
|
|
|
return *this;
|
2015-03-28 18:46:40 +00:00
|
|
|
}
|
|
|
|
|
2016-02-01 15:16:00 +00:00
|
|
|
|
2015-03-28 18:46:40 +00:00
|
|
|
void Free()
|
|
|
|
{
|
|
|
|
DeleteSamples(mPtr);
|
|
|
|
mPtr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
samplePtr ptr() const { return mPtr; }
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
2015-05-29 18:09:48 +00:00
|
|
|
samplePtr mPtr;
|
2015-03-28 18:46:40 +00:00
|
|
|
};
|
|
|
|
|
2016-02-01 15:16:00 +00:00
|
|
|
class GrowableSampleBuffer : private SampleBuffer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GrowableSampleBuffer()
|
|
|
|
: SampleBuffer()
|
|
|
|
, mCount(0)
|
|
|
|
{}
|
|
|
|
|
|
|
|
GrowableSampleBuffer(int count, sampleFormat format)
|
|
|
|
: SampleBuffer(count, format)
|
|
|
|
, mCount(count)
|
|
|
|
{}
|
|
|
|
|
|
|
|
GrowableSampleBuffer &Resize(int count, sampleFormat format)
|
|
|
|
{
|
|
|
|
if (!ptr() || mCount < count) {
|
|
|
|
Allocate(count, format);
|
|
|
|
mCount = count;
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Free()
|
|
|
|
{
|
|
|
|
SampleBuffer::Free();
|
|
|
|
mCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
using SampleBuffer::ptr;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int mCount;
|
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
//
|
|
|
|
// Copying, Converting and Clearing Samples
|
|
|
|
//
|
|
|
|
|
|
|
|
void CopySamples(samplePtr src, sampleFormat srcFormat,
|
|
|
|
samplePtr dst, sampleFormat dstFormat,
|
|
|
|
unsigned int len, bool highQuality=true,
|
2013-09-19 07:30:58 +00:00
|
|
|
unsigned int srcStride=1,
|
|
|
|
unsigned int dstStride=1);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void CopySamplesNoDither(samplePtr src, sampleFormat srcFormat,
|
|
|
|
samplePtr dst, sampleFormat dstFormat,
|
|
|
|
unsigned int len,
|
2013-09-19 07:30:58 +00:00
|
|
|
unsigned int srcStride=1,
|
|
|
|
unsigned int dstStride=1);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void ClearSamples(samplePtr buffer, sampleFormat format,
|
|
|
|
int start, int len);
|
|
|
|
|
2015-04-16 21:35:58 +00:00
|
|
|
void ReverseSamples(samplePtr buffer, sampleFormat format,
|
|
|
|
int start, int len);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
//
|
2016-02-13 15:43:16 +00:00
|
|
|
// This must be called on startup and everytime NEW ditherers
|
2010-01-23 19:44:49 +00:00
|
|
|
// are set in preferences.
|
|
|
|
//
|
|
|
|
|
|
|
|
void InitDitherers();
|
|
|
|
|
|
|
|
#endif
|