@@ -68,7 +68,7 @@ Audio_File::read_peaks( float fpp, nframes_t start, nframes_t end, int *peaks, P | |||||
*pbuf = new Peak[ *peaks * *channels ]; | *pbuf = new Peak[ *peaks * *channels ]; | ||||
/* deinterlace */ | |||||
/* deintereave peaks */ | |||||
int k = 0; | int k = 0; | ||||
for ( int i = 0; i < *channels; i++ ) | for ( int i = 0; i < *channels; i++ ) | ||||
for ( int j = i; j < *peaks * *channels; j += *channels ) | for ( int j = i; j < *peaks * *channels; j += *channels ) | ||||
@@ -19,6 +19,8 @@ | |||||
#include "Audio_Track.H" | #include "Audio_Track.H" | ||||
#include "dsp.h" | |||||
#include <Fl/fl_ask.H> | #include <Fl/fl_ask.H> | ||||
static | static | ||||
@@ -142,18 +144,9 @@ Audio_Track::play ( sample_t *buf, nframes_t frame, nframes_t nframes, int chann | |||||
continue; | continue; | ||||
if ( channels == 1 ) | if ( channels == 1 ) | ||||
{ | |||||
// memcpy( buf, cbuf, nframes * sizeof( sample_t ) ); | |||||
for ( unsigned int j = 0; j < nfr; ++j ) | |||||
buf[ j ] += cbuf[ j ]; | |||||
} | |||||
buffer_mix( buf, cbuf, nframes ); | |||||
else | else | ||||
{ | |||||
/* mix and interleave */ | |||||
int k = 0; | |||||
for ( unsigned int j = i; k < nfr; j += channels ) | |||||
buf[ j ] += cbuf[ k++ ]; | |||||
} | |||||
buffer_interleave_one_channel_and_mix( buf, cbuf, i, channels, nframes ); | |||||
} | } | ||||
} | } | ||||
@@ -13,6 +13,7 @@ SRCS= \ | |||||
Audio_File_SF.C \ | Audio_File_SF.C \ | ||||
Port.C \ | Port.C \ | ||||
Disk_Stream.C \ | Disk_Stream.C \ | ||||
dsp.c \ | |||||
Engine.C \ | Engine.C \ | ||||
Transport.C \ | Transport.C \ | ||||
Loggable.C \ | Loggable.C \ | ||||
@@ -22,6 +22,8 @@ | |||||
#include "Timeline.H" | #include "Timeline.H" | ||||
#include "Waveform.H" | #include "Waveform.H" | ||||
#include "dsp.h" | |||||
#include <FL/fl_draw.H> | #include <FL/fl_draw.H> | ||||
#include <FL/Fl.H> | #include <FL/Fl.H> | ||||
#include <FL/Fl_Group.H> | #include <FL/Fl_Group.H> | ||||
@@ -850,9 +852,7 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co | |||||
/* apply gain */ | /* apply gain */ | ||||
if ( _scale != 1.0f ) | |||||
for ( int i = cnt; i--; ) | |||||
buf[i] *= _scale; | |||||
buffer_apply_gain( buf, cnt, _scale ); | |||||
/* perform declicking if necessary */ | /* perform declicking if necessary */ | ||||
@@ -0,0 +1,94 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* 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. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
/* General DSP related functions. */ | |||||
#include "dsp.h" | |||||
/* TODO: these functions are all targets for optimization (SSE?) */ | |||||
void | |||||
buffer_apply_gain ( sample_t *buf, nframes_t nframes, float g ) | |||||
{ | |||||
if ( g != 1.0f ) | |||||
while ( nframes-- ) | |||||
*(buf++) *= g; | |||||
} | |||||
void | |||||
buffer_apply_gain_buffer ( sample_t *buf, sample_t *gainbuf, nframes_t nframes ) | |||||
{ | |||||
while ( nframes-- ) | |||||
*(buf++) *= *(gainbuf++); | |||||
} | |||||
void | |||||
buffer_mix ( sample_t *dst, sample_t *src, nframes_t nframes ) | |||||
{ | |||||
while ( nframes-- ) | |||||
*(dst++) += *(src++); | |||||
} | |||||
void | |||||
buffer_mix_with_gain ( sample_t *dst, sample_t *src, nframes_t nframes, float g ) | |||||
{ | |||||
while ( nframes-- ) | |||||
*(dst++) += *(src++) * g; | |||||
} | |||||
void | |||||
buffer_interleave_one_channel ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ) | |||||
{ | |||||
nframes *= channels; | |||||
dst += channel; | |||||
while ( nframes-- ) | |||||
{ | |||||
*dst = *(src++); | |||||
dst += channels; | |||||
} | |||||
} | |||||
void | |||||
buffer_interleave_one_channel_and_mix ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ) | |||||
{ | |||||
nframes *= channels; | |||||
dst += channel; | |||||
while ( nframes-- ) | |||||
{ | |||||
*dst += *(src++); | |||||
dst += channels; | |||||
} | |||||
} | |||||
void | |||||
buffer_deinterleave_one_channel ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ) | |||||
{ | |||||
nframes *= channels; | |||||
src += channel; | |||||
while ( nframes-- ) | |||||
{ | |||||
*(dst++) = *src; | |||||
src += channels; | |||||
} | |||||
} |
@@ -0,0 +1,30 @@ | |||||
/*******************************************************************************/ | |||||
/* Copyright (C) 2008 Jonathan Moore Liles */ | |||||
/* */ | |||||
/* 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. */ | |||||
/* */ | |||||
/* This program is distributed in the hope that it will be useful, but WITHOUT */ | |||||
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ | |||||
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for */ | |||||
/* more details. */ | |||||
/* */ | |||||
/* You should have received a copy of the GNU General Public License along */ | |||||
/* with This program; see the file COPYING. If not,write to the Free Software */ | |||||
/* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||||
/*******************************************************************************/ | |||||
#pragma once | |||||
#include "types.h" | |||||
void buffer_apply_gain ( sample_t *buf, nframes_t nframes, float g ); | |||||
void buffer_apply_gain_buffer ( sample_t *buf, sample_t *gainbuf, nframes_t nframes ); | |||||
void buffer_mix ( sample_t *dst, sample_t *src, nframes_t nframes ); | |||||
void buffer_mix_with_gain ( sample_t *dst, sample_t *src, nframes_t nframes, float g ); | |||||
void buffer_interleave_one_channel ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ); | |||||
void buffer_interleave_one_channel_and_mix ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ); | |||||
void buffer_deinterleave_one_channel ( sample_t *dst, sample_t *src, int channel, int channels, nframes_t nframes ); |