# Audacity 1.1.0 Phonograph Patch # # By Doug Hoyte # # This patch adds an effect "Phonograph", which creates pops and crackles # that sound somewhat like a 33 1/3 LP in the selected audio # # Apply like so: # # cd audacity-1.1.0/ # patch -p1 < /tmp/audacity-src-1.1.0-phonograph.patch # # Replace /tmp/ with wherever you put the patch, obviously. # configure, make, and enjoy. # # # diff -urNB audacity-src-1.1.0/src/Makefile.in audacity-src-1.1.0-phonograph/src/Makefile.in --- audacity-src-1.1.0/src/Makefile.in Wed Jun 5 00:45:54 2002 +++ audacity-src-1.1.0-phonograph/src/Makefile.in Fri Aug 9 16:32:29 2002 @@ -76,6 +76,7 @@ $(OBJDIR)/effects/Invert.o \ $(OBJDIR)/effects/NoiseRemoval.o \ $(OBJDIR)/effects/Phaser.o \ + $(OBJDIR)/effects/Phonograph.o \ $(OBJDIR)/effects/Reverse.o \ $(OBJDIR)/effects/Wahwah.o \ $(OBJDIR)/export/Export.o \ diff -urNB audacity-src-1.1.0/src/effects/LoadEffects.cpp audacity-src-1.1.0-phonograph/src/effects/LoadEffects.cpp --- audacity-src-1.1.0/src/effects/LoadEffects.cpp Wed Jun 5 00:45:54 2002 +++ audacity-src-1.1.0-phonograph/src/effects/LoadEffects.cpp Fri Aug 9 16:33:33 2002 @@ -21,6 +21,7 @@ #include "Invert.h" #include "NoiseRemoval.h" #include "Phaser.h" +#include "Phonograph.h" #include "Reverse.h" #include "Wahwah.h" @@ -52,6 +53,7 @@ Effect::RegisterEffect(new EffectInvert(), false); Effect::RegisterEffect(new EffectNoiseRemoval(), false); Effect::RegisterEffect(new EffectPhaser(), false); + Effect::RegisterEffect(new EffectPhonograph(), false); Effect::RegisterEffect(new EffectReverse(), false); Effect::RegisterEffect(new EffectWahwah(), false); diff -urNB audacity-src-1.1.0/src/effects/Phonograph.cpp audacity-src-1.1.0-phonograph/src/effects/Phonograph.cpp --- audacity-src-1.1.0/src/effects/Phonograph.cpp Wed Dec 31 16:00:00 1969 +++ audacity-src-1.1.0-phonograph/src/effects/Phonograph.cpp Fri Aug 9 16:31:04 2002 @@ -0,0 +1,89 @@ +/********************************************************************** + + Audacity: A Digital Audio Editor + + Phonograph.cpp + + Doug Hoyte + + This class gives the selection the good ol' fashion vibe of a + 33 1/3 LP. + +**********************************************************************/ + +#include + + +#include "Phonograph.h" +#include "../WaveTrack.h" + +// +// EffectPhonograph +// + +EffectPhonograph::EffectPhonograph() +{ +} + +bool EffectPhonograph::Process() +{ + TrackListIterator iter(mWaveTracks); + VTrack *t = iter.First(); + int count = 0; + while(t) { + sampleCount start, len; + GetSamples((WaveTrack *)t, &start, &len); + bool success = ProcessOne(count, (WaveTrack *)t, start, len); + + if (!success) + return false; + + t = iter.Next(); + count++; + } + + return true; +} + +bool EffectPhonograph::ProcessOne(int count, WaveTrack *t, + sampleCount start, sampleCount len) +{ + sampleCount base = start; + float *buf = new float[len]; + + int j,next,tpwidth=0; + float tpheight,tpoff; + + + srand(time(NULL)); + + t->Get(buf, base, len); + + next = 5500+(int) (7500.0*rand()/(RAND_MAX+1.0)); + for (int i = 0; i < len; i++) { + + next--; + if(next <= 0) { + next = 5500+(int) (7500.0*rand()/(RAND_MAX+1.0)); + tpheight = (0.2*rand()/(RAND_MAX+1.0)); + tpwidth = 7+(int) (50.0*rand()/(RAND_MAX+1.0)); + + if (next%2 == 0) tpheight *= -1; + + for (j = 0; j < tpwidth; j++) { + tpoff = (0.1*rand()/(RAND_MAX+1.0)); + tpoff *= tpheight; + if (i+j < len) buf[i+j] += tpheight + tpoff; + } + + } + + + } + + t->Set(buf, base, len); + + delete[] buf; + + return true; +} diff -urNB audacity-src-1.1.0/src/effects/Phonograph.h audacity-src-1.1.0-phonograph/src/effects/Phonograph.h --- audacity-src-1.1.0/src/effects/Phonograph.h Wed Dec 31 16:00:00 1969 +++ audacity-src-1.1.0-phonograph/src/effects/Phonograph.h Fri Aug 9 16:31:04 2002 @@ -0,0 +1,55 @@ +/********************************************************************** + + Audacity: A Digital Audio Editor + + Phonograph.h + + Doug Hoyte + + This class gives the selection the good ol' fashion vibe of a + 33 1/3 LP. + +**********************************************************************/ + +#ifndef __AUDACITY_EFFECT_PHONOGRAPH__ +#define __AUDACITY_EFFECT_PHONOGRAPH__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Effect.h" + +#define __UNINITIALIZED__ (-1) + +class WaveTrack; + +class EffectPhonograph:public Effect { + + public: + EffectPhonograph(); + + virtual wxString GetEffectName() { + return wxString(_("Phonograph")); + } + + virtual wxString GetEffectAction() { + return wxString(_("\"Phonographing\"")); + } + + virtual bool Process(); + + private: + bool ProcessOne(int count, WaveTrack * t, + sampleCount start, sampleCount len); + + private: + +}; + +#endif