コード例 #1
0
FFTSenderUGenInternal::FFTSenderUGenInternal(UGen const& input, 
											 FFTEngine::FFTModes mode,
											 FFTEngine const& fft, 
											 const int overlap,
											 const int firstBin,
											 const int numBins) throw()
:	UGenInternal(NumInputs),	
	mode_(mode),
	fftEngine(fft),
	fftSize(fftEngine.size()),
	fftSizeHalved(fftSize / 2),
	overlap_(overlap < 1 ? 1 : overlap),
	firstBin_(firstBin < fftSizeHalved ? firstBin : fftSizeHalved),
	maxNumBins(fftSizeHalved - firstBin_ + 1),
	numBins_(numBins ? (numBins < maxNumBins ? numBins : maxNumBins) : maxNumBins),
	inputBuffer(Buffer::newClear(fftSize, input.getNumChannels(), true)),
	outputBuffer(Buffer::newClear(fftSize, input.getNumChannels(), true)),
	bufferIndex(0)
{
	ugen_assert(overlap == overlap_);	// should be > 0
	ugen_assert(firstBin == firstBin_);	// should be in range
//	ugen_assert(numBins == numBins_);	// should be in range	
	
	inputs[Input] = input;	
}
コード例 #2
0
BEGIN_UGEN_NAMESPACE

#include "ugen_DiskOut.h"
#include "../ugen_JuceUtility.h"


DiskOutUGenInternal::DiskOutUGenInternal(File const& file, UGen const& input, bool overwriteExisitingFile, int bitDepth) throw()
:	ProxyOwnerUGenInternal(NumInputs, input.getNumChannels()-1),
	audioFormatWriter(0),
	bufferData(0),
	numInputChannels(input.getNumChannels())
{
	ugen_assert(bitDepth >= 16);
	
	inputs[Input] = input;
	
	bufferData = new float*[numInputChannels];
	memset(bufferData, 0, numInputChannels * sizeof(float*));
	
	File outputFile(file);
	
	if(outputFile.getFileExtension().isEmpty())
		outputFile = outputFile.withFileExtension("wav");
	
	if(overwriteExisitingFile == true && outputFile.exists())
		outputFile.deleteFile();
	else if(outputFile.exists())
	{
		ugen_assertfalse;
		return;
	}
	
	if(outputFile.hasFileExtension(".wav"))
	{
		WavAudioFormat wavAudioFormat;
		FileOutputStream* fileOutputStream = outputFile.createOutputStream();
		
		if(fileOutputStream)
			audioFormatWriter = wavAudioFormat.createWriterFor(fileOutputStream, 
															   UGen::getSampleRate(), 
															   numInputChannels, 
															   bitDepth, 0, 0);
	}
	else if(outputFile.hasFileExtension(".aif") 
			|| outputFile.hasFileExtension(".aiff"))
	{
		AiffAudioFormat aiffAudioFormat;
		FileOutputStream* fileOutputStream = outputFile.createOutputStream();
		
		if(fileOutputStream)
			audioFormatWriter = aiffAudioFormat.createWriterFor(fileOutputStream, 
																UGen::getSampleRate(), 
																numInputChannels, 
																bitDepth, 0, 0);
	}
		
}
コード例 #3
0
ファイル: ugen_HPF.cpp プロジェクト: alessandrostone/ugen
HPF::HPF(UGen const& input, UGen const& freq) throw()
{
	int numChannels = 1;
	numChannels = input.getNumChannels() > numChannels ? input.getNumChannels()	: numChannels;
	numChannels = freq.getNumChannels()	 > numChannels ? freq.getNumChannels()	: numChannels;
	
	initInternal(numChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new HPFUGenInternal(input, freq);
	}
}
コード例 #4
0
ToggleFF::ToggleFF(UGen const& trig) throw()
{
	initInternal(trig.getNumChannels());	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new ToggleFFUGenInternal(trig);		
	}
}
コード例 #5
0
ファイル: ugen_FSinOsc.cpp プロジェクト: kazu2012/ofxUGen
FSinOsc::FSinOsc(UGen const& freq) throw()
{	
	initInternal(freq.getNumChannels());
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new FSinOscUGenInternal(freq, 0.f, i);
	}
}
コード例 #6
0
ファイル: ugen_Correlation.cpp プロジェクト: kazu2012/ofxUGen
Correlation::Correlation(UGen const& inputA, 
                         UGen const& inputB, 
                         const int length, 
                         const int initialDelay) throw()
{	
	const int lengthChecked = ugen::clip(length, 1, 2044);

	const int numInputChannels = ugen::max(inputA.getNumChannels(), inputB.getNumChannels());
	initInternal(numInputChannels);
	
	for(int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new CorrelationUGenInternal(inputA, 
                                                       inputB, 
                                                       lengthChecked, 
                                                       initialDelay);
	}
}
コード例 #7
0
BlockDelay::BlockDelay(UGen const& input) throw()
{
	int numChannels = input.getNumChannels();
	initInternal(numChannels);
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new BlockDelayUGenInternal(input);
	}
}
コード例 #8
0
ファイル: ugen_Trig.cpp プロジェクト: alessandrostone/ugen
Trig::Trig(UGen const& input) throw()
{
	initInternal(input.getNumChannels());
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new TrigUGenInternal(input);
	}
}
コード例 #9
0
ファイル: ugen_TableOsc.cpp プロジェクト: kazu2012/ofxUGen
SinOsc::SinOsc(UGen const& freq, Buffer const& initialPhase) throw()
{	
	int numChannels = ugen::max(freq.getNumChannels(), initialPhase.size());
	
	initInternal(numChannels);
		
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new TableOscUGenInternal(freq, initialPhase.wrapAt(i), Buffer::getTableSine8192());
	}
}
コード例 #10
0
BufferSenderUGenInternal::BufferSenderUGenInternal(UGen const& input, UGen const& duration) throw()
:	UGenInternal(NumInputs),
	audioBuffer(Buffer::withSize((int)(UGen::getSampleRate()), input.getNumChannels(), true)),
	bufferIndex(0),
	audioBufferSizeUsed(0),
	samplesProcessed(0)
{	
	inputs[Input] = input;
	inputs[Duration] = duration;
	
	audioBufferSizeUsed = max(1, (int)(duration.getValue() * UGen::getSampleRate() + 0.5));
}
コード例 #11
0
BEGIN_UGEN_NAMESPACE

#include "ugen_JuceMultiSlider.h"



MultiSliderUGenInternal::MultiSliderUGenInternal(UGen const& input, MultiSlider *_sliders) throw()
:	ProxyOwnerUGenInternal(NumInputs, input.getNumChannels()-1),
	sliders(_sliders->attachToMultiSliderUGenInternal() ? _sliders : 0),
	values(sliders && input.getNumChannels() ? new double[input.getNumChannels()] : 0)
{
	inputs[Input] = input;
		
	if(values)
		memset(values, 0, input.getNumChannels() * sizeof(double));
	
	if(sliders)// && sliders->isValidComponent())
	{
		sliders->getInterceptsMouseClicks(oldClick, oldChildClick);
		sliders->setInterceptsMouseClicks(false, false);
		
		sliders->setNumSliders(input.getNumChannels());
		for(int i = 0; i < input.getNumChannels(); i++)
		{
			values[i] = sliders->getSlider(i)->getValue();
		}
		
		startTimer(40);
	}
}
コード例 #12
0
ファイル: ugen_TableOsc.cpp プロジェクト: kazu2012/ofxUGen
TableOsc::TableOsc(Buffer const& table, UGen const& freq, Buffer const& initialPhase) throw()
{	
	// could check here that the table is padded appropriately and use a less efficient version if not
	
	int numChannels = ugen::max(freq.getNumChannels(), initialPhase.size());
	
	initInternal(numChannels);
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new TableOscUGenInternal(freq, initialPhase.wrapAt(i), table);
	}
}
コード例 #13
0
karplusUGen::karplusUGen(UGen const& input,
						const float minFreq,
						UGen const& fundamental,
						UGen const& decayTime,
						UGen const& cutoff) throw()
{
	initInternal(input.getNumChannels());
	
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new karplusUGenInternal(input, minFreq, fundamental, decayTime, cutoff);
	}
}
コード例 #14
0
ファイル: ugen_PlayBuf.cpp プロジェクト: alessandrostone/ugen
RecordBuf::RecordBuf(UGen const& input,
					 Buffer const& buffer, 
					 UGen const& recLevel,
					 UGen const& preLevel,
					 UGen const& loop, 
					 const UGen::DoneAction doneAction) throw()
{
	ugen_assert(buffer.size() > 0);
	ugen_assert(buffer.getNumChannels() > 0);

	const int numChannels = ugen::max(buffer.getNumChannels(), input.getNumChannels());
	initInternal(numChannels);
	generateFromProxyOwner(new RecordBufUGenInternal(input, buffer, recLevel, preLevel, loop.mix(), doneAction));
}
コード例 #15
0
BEGIN_UGEN_NAMESPACE

#include "ugen_iPhoneAudioFileDiskOut.h"
#include "ugen_NSUtilities.h"

DiskOutUGenInternal::DiskOutUGenInternal(AudioFileID audioFile, AudioStreamBasicDescription const& format, UGen const& input) throw()
:	ProxyOwnerUGenInternal(NumInputs, input.getNumChannels() - 1),
	audioFile_(audioFile),
	numChannels(input.getNumChannels()),
	currentPacket(0),
	allocatedBlockSize(0),
	allocatedBlockSizeInBytes(0),
	audioData(0),
	bytesPerFrame(format.mBytesPerFrame)
{
	inputs[Input] = input;
	
	if(audioFile_)
	{
		allocatedBlockSize = UGen::getEstimatedBlockSize();
		allocatedBlockSizeInBytes = allocatedBlockSize * bytesPerFrame;
		audioData = malloc(allocatedBlockSizeInBytes + 4); // pad a little for 24 bit
	}	
}
コード例 #16
0
ファイル: ugen_PlayBuf.cpp プロジェクト: alessandrostone/ugen
RecordBufUGenInternal::RecordBufUGenInternal(UGen const& input,
											 Buffer const& buffer, 
											 UGen const& recLevel,
											 UGen const& preLevel,
											 UGen const& loop, 
											 const UGen::DoneAction doneAction) throw()
:	ProxyOwnerUGenInternal(NumInputs, ugen::max(buffer.getNumChannels(), input.getNumChannels()) - 1),
	buffer_(buffer),
	bufferPos(0),
	doneAction_(doneAction),
	shouldDeleteValue(doneAction_ == UGen::DeleteWhenDone)
{
	inputs[Input] = input;
	inputs[RecLevel] = recLevel;
	inputs[PreLevel] = preLevel;
	inputs[Loop] = loop;
}
コード例 #17
0
BEGIN_UGEN_NAMESPACE

#include "../core/ugen_UGenArray.h"
#include "../buffers/ugen_Buffer.h"
#include "ugen_UnaryOpUGens.h"

UnaryOpUGenInternal::UnaryOpUGenInternal(UGen const& operand, const int channel) throw()
    :	UGenInternal(NumInputs)
{
    if(channel < 0)
        inputs[Operand] = operand;
    else
    {
        int numChannels = operand.getNumChannels();
        UGenInternal* internal = operand.getInternalUGen(channel % numChannels);
        inputs[Operand] = UGen(internal->getChannelInternal(channel), channel);
    }
}
コード例 #18
0
bool DiskOut::initWithAudioFileAiff32(const char *audioFilePath, 
									  UGen const& input, 
									  bool overwriteExisitingFile) throw()
{
	Text path; // this needs to be here so it doesn't get garbage collected too early
	
	if(audioFilePath[0] != '/')
	{	
		path = NSUtilities::pathInDirectory(NSUtilities::Documents, audioFilePath);
		audioFilePath = path.getArray();
	}
	
	CFURLRef fileURL = CFURLCreateFromFileSystemRepresentation(NULL, 
															   (UInt8*)audioFilePath, 
															   strlen(audioFilePath), 
															   false);
	
	AudioStreamBasicDescription format;
	
	const int numChannels = input.getNumChannels();
	
	format.mChannelsPerFrame	= numChannels;
	format.mSampleRate			= UGen::getSampleRate();
	format.mFormatID			= kAudioFormatLinearPCM;
	format.mFormatFlags			= kAudioFormatFlagIsBigEndian | kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
	format.mBitsPerChannel		= 32;
	format.mBytesPerFrame		= format.mChannelsPerFrame * format.mBitsPerChannel / 8;
	format.mFramesPerPacket		= 1;
	format.mBytesPerPacket		= format.mBytesPerFrame * format.mFramesPerPacket;
	
	AudioFileID	audioFile;
	OSStatus status = AudioFileCreateWithURL(fileURL,
											 kAudioFileAIFFType,
											 &format,
											 overwriteExisitingFile ? kAudioFileFlags_EraseFile : 0,
											 &audioFile);
	
	if(status != noErr) return false;
	
	initInternal(numChannels);
	generateFromProxyOwner(new DiskOutUGenInternalAiff32(audioFile, format, input));
	
	return true;	
}
コード例 #19
0
void DiskOut::initWithJuceFile(File const& file, UGen const& input, bool overwriteExisitingFile, int bitDepth) throw()
{
	DiskOutUGenInternal* internal;
	
	if(file.isDirectory()) 
	{
		internal = new DiskOutUGenInternal(file.getChildFile(getFileNameWithTimeIdentifier("DiskOut")), 
										   input, 
										   overwriteExisitingFile, 
										   bitDepth);
	}
	else
	{
		internal = new DiskOutUGenInternal(file, input, overwriteExisitingFile, bitDepth);
	}
	
	initInternal(input.getNumChannels());
	generateFromProxyOwner(internal);
}
コード例 #20
0
ファイル: ugen_TableOsc.cpp プロジェクト: kazu2012/ofxUGen
HarmonicOsc::HarmonicOsc(Buffer const& harmonicWeights, UGen const& freq, Buffer const& initialPhase) throw()
{	
	int numChannels = ugen::max(freq.getNumChannels(), initialPhase.size());
	
	initInternal(numChannels);
	
	Buffer table(BufferSpec(8193, 1, true));
	
	for(int harmonic = 1; harmonic <= harmonicWeights.size(); harmonic++)
	{
		float amp = harmonicWeights.getSampleUnchecked(0, harmonic-1);
		table += Buffer::line(8193, 0.0, harmonic * twoPi).sin() * amp;
	}
	
	table = table.shrinkSize();
	for(unsigned int i = 0; i < numInternalUGens; i++)
	{
		internalUGens[i] = new TableOscUGenInternal(freq, initialPhase.wrapAt(i), table);
	}
}
コード例 #21
0
MultiSliderUGen::MultiSliderUGen(UGen const& input, MultiSlider *sliders) throw()
{
	MultiSliderUGenInternal *internal = new MultiSliderUGenInternal(input, sliders);
	initInternal(input.getNumChannels());
	generateFromProxyOwner(internal);
}