/[svn]/linuxsampler/trunk/src/drivers/audio/AudioChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/audio/AudioChannel.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2376 by schoenebeck, Sat Jul 4 12:31:44 2009 UTC revision 2377 by schoenebeck, Thu Oct 4 18:16:26 2012 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2012 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 115  namespace LinuxSampler { Line 115  namespace LinuxSampler {
115       * @param Samples - amount of sample points to be copied       * @param Samples - amount of sample points to be copied
116       */       */
117      void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples) {      void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples) {
118          memcpy(pDst->Buffer(), Buffer(), Samples * sizeof(float));          memcpy((float* __restrict)pDst->Buffer(), (const float* __restrict)Buffer(), Samples * sizeof(float));
119      }      }
120    
121      /**      /**
# Line 133  namespace LinuxSampler { Line 133  namespace LinuxSampler {
133      void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples, const float fLevel) {      void AudioChannel::CopyTo(AudioChannel* pDst, const uint Samples, const float fLevel) {
134          if (fLevel == 1.0f) CopyTo(pDst, Samples);          if (fLevel == 1.0f) CopyTo(pDst, Samples);
135          else {          else {
136              float* pSrcBuf = Buffer();              const float* __restrict pSrcBuf = Buffer();
137              float* pDstBuf = pDst->Buffer();              float* __restrict pDstBuf = pDst->Buffer();
138              #if HAVE_GCC_VECTOR_EXTENSIONS              #if HAVE_GCC_VECTOR_EXTENSIONS
139              if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {              if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {
140                  const v4sf vcoeff = { fLevel, fLevel, fLevel, fLevel };                  const v4sf vcoeff = { fLevel, fLevel, fLevel, fLevel };
141                  const v4sf* src = static_cast<v4sf*>((void*)Buffer());                  const v4sf* __restrict src =
142                  v4sf* dst       = static_cast<v4sf*>((void*)pDst->Buffer());                      static_cast<const v4sf* __restrict>(
143                            (const void* __restrict)pSrcBuf
144                        );
145                    v4sf* __restrict dst =
146                         static_cast<v4sf* __restrict>(
147                             (void* __restrict)pDstBuf
148                         );
149                  const int cells = Samples / 4;                  const int cells = Samples / 4;
150                  for (int i = 0; i < cells; ++i)                  for (int i = 0; i < cells; ++i)
151                      dst[i] = src[i] * vcoeff;                      dst[i] = src[i] * vcoeff;
# Line 161  namespace LinuxSampler { Line 167  namespace LinuxSampler {
167       * @param Samples - amount of sample points to be mixed over       * @param Samples - amount of sample points to be mixed over
168       */       */
169      void AudioChannel::MixTo(AudioChannel* pDst, const uint Samples) {      void AudioChannel::MixTo(AudioChannel* pDst, const uint Samples) {
170          float* pSrcBuf = Buffer();          const float* __restrict pSrcBuf = Buffer();
171          float* pDstBuf = pDst->Buffer();          float* __restrict pDstBuf = pDst->Buffer();
172          #if HAVE_GCC_VECTOR_EXTENSIONS          #if HAVE_GCC_VECTOR_EXTENSIONS
173          if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {          if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {
174              const v4sf* src = static_cast<v4sf*>((void*)Buffer());              const v4sf* __restrict src =
175              v4sf* dst       = static_cast<v4sf*>((void*)pDst->Buffer());                  static_cast<const v4sf* __restrict>(
176                        (const void* __restrict)pSrcBuf
177                    );
178                v4sf* __restrict dst =
179                    static_cast<v4sf* __restrict>(
180                        (void* __restrict)pDstBuf
181                    );
182              const int cells = Samples / 4;              const int cells = Samples / 4;
183              for (int i = 0; i < cells; ++i)              for (int i = 0; i < cells; ++i)
184                  dst[i] += src[i];                  dst[i] += src[i];
# Line 191  namespace LinuxSampler { Line 203  namespace LinuxSampler {
203      void AudioChannel::MixTo(AudioChannel* pDst, const uint Samples, const float fLevel) {      void AudioChannel::MixTo(AudioChannel* pDst, const uint Samples, const float fLevel) {
204          if (fLevel == 1.0f) MixTo(pDst, Samples);          if (fLevel == 1.0f) MixTo(pDst, Samples);
205          else {          else {
206              float* pSrcBuf = Buffer();              const float* __restrict pSrcBuf = Buffer();
207              float* pDstBuf = pDst->Buffer();              float* __restrict pDstBuf = pDst->Buffer();
208              #if HAVE_GCC_VECTOR_EXTENSIONS              #if HAVE_GCC_VECTOR_EXTENSIONS
209              if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {              if ((size_t)pSrcBuf % 16 == 0 && (size_t)pDstBuf % 16 == 0) {
210                  const v4sf vcoeff = { fLevel, fLevel, fLevel, fLevel };                  const v4sf vcoeff = { fLevel, fLevel, fLevel, fLevel };
211                  const v4sf* src = static_cast<v4sf*>((void*)Buffer());                  const v4sf* __restrict src =
212                  v4sf* dst       = static_cast<v4sf*>((void*)pDst->Buffer());                      static_cast<const v4sf* __restrict>(
213                            (const void* __restrict)pSrcBuf
214                        );
215                    v4sf* __restrict dst =
216                        static_cast<v4sf* __restrict>(
217                            (void* __restrict)pDstBuf
218                        );
219                  const int cells = Samples / 4;                  const int cells = Samples / 4;
220                  for (int i = 0; i < cells; ++i)                  for (int i = 0; i < cells; ++i)
221                      dst[i] += src[i] * vcoeff;                      dst[i] += src[i] * vcoeff;

Legend:
Removed from v.2376  
changed lines
  Added in v.2377

  ViewVC Help
Powered by ViewVC