Beispiel #1
0
IoAudioDevice *IoAudioDevice_proto(void *state)
{
	IoObject *self = IoObject_new(state);
	IoObject_tag_(self, IoAudioDevice_newTag(state));

	IoObject_setDataPointer_(self, calloc(1, sizeof(IoAudioDeviceData)));

	DATA(self)->writeBuffer = IoSeq_new(state);
	DATA(self)->readBuffer = IoSeq_new(state);
	DATA(self)->audioDevice = AudioDevice_new();
	IoState_registerProtoWithFunc_(state, self, IoAudioDevice_proto);

	{
	IoMethodTable methodTable[] = {
	{"open", IoAudioDevice_open},
	{"openForReadingAndWriting", IoAudioDevice_openForReadingAndWriting},
	{"close", IoAudioDevice_close},
	{"asyncWrite", IoAudioDevice_asyncWrite},
	{"asyncRead", IoAudioDevice_read},
	{"error", IoAudioDevice_error},
	{"isActive", IoAudioDevice_isActive},
	{"streamTime", IoAudioDevice_streamTime},
	{"needsData", IoAudioDevice_needsData},
	{"writeBufferIsEmpty", IoAudioDevice_writeBufferIsEmpty},
	{NULL, NULL},
	};
	IoObject_addMethodTable_(self, methodTable);
	}
	return self;
}
Beispiel #2
0
IoMP3Decoder *IoMP3Decoder_proto(void *state)
{
	IoObject *self = IoObject_new(state);
	IoObject_tag_(self, IoMP3Decoder_newTag(state));
	
	IoObject_setDataPointer_(self, calloc(1, sizeof(IoMP3DecoderData)));
	
	//DATA(self)->outSound = 0x0;
	DATA(self)->willProcessMessage = IoMessage_newWithName_label_(state, IOSYMBOL("willProcess"), IOSYMBOL("[MP3Decoder]"));
	DATA(self)->didProcessMessage = IoMessage_newWithName_label_(state, IOSYMBOL("didProcess"), IOSYMBOL("[MP3Decoder]"));
	DATA(self)->inputBuffer  = IoSeq_new(state);
	DATA(self)->outputBuffer = IoSeq_new(state);
	DATA(self)->tmpInputBa = UArray_new();
	
	IoState_registerProtoWithFunc_(state, self, IoMP3Decoder_proto);
	
	{
		IoMethodTable methodTable[] = {
		{"start", IoMP3Decoder_start},
		{"stop",  IoMP3Decoder_stop},
		{"inputBuffer",  IoMP3Decoder_inputBuffer},
		{"outputBuffer",  IoMP3Decoder_outputBuffer},
		
		{NULL, NULL},
		};
		IoObject_addMethodTable_(self, methodTable);
	}
	return self;
}
Beispiel #3
0
IoSeq *IoSeq_newFromFilePath_(void *state, const char *path)
{
	IoSeq *self = IoSeq_new(state);
	UArray p = UArray_stackAllocedWithCString_((char *)path);
	UArray_readFromFilePath_(DATA(self), &p);
	return self;
}
Beispiel #4
0
IoSeq *IoSeq_newWithData_length_copy_(void *state, const unsigned char *s, size_t length, int copy)
{
	IoSeq *self = IoSeq_new(state);
	UArray_setData_type_size_copy_(DATA(self), (uint8_t *)s, CTYPE_uint8_t, length, copy);
	//UArray_convertToFixedSizeType(DATA(self));
	return self;
}
Beispiel #5
0
IoAudioMixer *IoAudioMixer_rawClone(IoAudioMixer *proto) 
{ 
	IoObject *self = IoObject_rawClonePrimitive(proto);
	self->data = cpalloc(proto->data, sizeof(IoAudioMixerData));
	
	DATA(self)->ioBuffer = IoSeq_new(IOSTATE);
	DATA(self)->buffer = IoSeq_rawUArray(DATA(self)->ioBuffer);
	DATA(proto)->mixBuffer = UArray_new();
	DATA(self)->writeMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("write"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->writeMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->nonBlockingWriteMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("nonBlockingWrite"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->nonBlockingWriteMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->sounds = List_new();
	DATA(self)->soundsToRemove = List_new();
	DATA(self)->events = List_new();
	DATA(self)->activeEvents = List_new();
	DATA(self)->volume = DATA(self)->volume;
	
	DATA(self)->soundTouch = SoundTouch_init();
	SoundTouch_setSampleRate(DATA(self)->soundTouch, 44100);
	SoundTouch_setChannels(DATA(self)->soundTouch, 2);
	DATA(self)->tempo = 1.0;
	IoState_addValue_(IOSTATE, self);
	return self; 
}
Beispiel #6
0
IoAVCodec *IoAVCodec_proto(void *state)
{
	IoObject *self = IoObject_new(state);
	IoObject_tag_(self, IoAVCodec_newTag(state));

	IoObject_setDataPointer_(self, calloc(1, sizeof(IoAVCodecData)));

	DATA(self)->inputBuffer  = IoSeq_new(state);
	DATA(self)->outputBuffer = IoSeq_new(state);

	IoState_registerProtoWithFunc_(state, self, IoAVCodec_proto);

	IoAVCodec_registerIfNeeded(self);

	{
		IoMethodTable methodTable[] = {

		{"audioInputBuffer",  IoAVCodec_audioInputBuffer},
		{"audioOutputBuffer", IoAVCodec_audioOutputBuffer},

		{"encodeCodecNames",  IoAVCodec_encodeCodecNames},
		{"decodeCodecNames",  IoAVCodec_decodeCodecNames},

		{"open", IoAVCodec_open},
		{"close", IoAVCodec_close},

		{"decode", IoAVCodec_decode},
		{"isAtEnd", IoAVCodec_isAtEnd},
		//{"encode",     IoAVCodec_startEncoding},

		{NULL, NULL},
		};
		IoObject_addMethodTable_(self, methodTable);
	}
	return self;
}
Beispiel #7
0
IoSymbol *IoSeq_newSymbolWithUArray_copy_(void *state, UArray *ba, int copy)
{
	IoObject *self = IoSeq_new(state);

	if (copy)
	{
		UArray_copy_(DATA(self), ba);
	}
	else
	{
		UArray_free(DATA(self));
		IoObject_setDataPointer_(self, ba);
	}

	return self;
}
Beispiel #8
0
IoSymbol *IoSeq_newSymbolWithData_length_(void *state, const char *s, size_t length)
{
	IoObject *self = IoSeq_new(state);
	UArray_setData_type_size_copy_(DATA(self), (unsigned char *)s, CTYPE_uint8_t, length, 1);
	return self;
}
Beispiel #9
0
IoAudioMixer *IoAudioMixer_proto(void *state)
{
	IoObject *self = IoObject_new(state);
	IoObject_tag_(self, IoAudioMixer_newTag(state));
	
	self->data = calloc(1, sizeof(IoAudioMixerData));
	DATA(self)->sounds = List_new();
	DATA(self)->soundsToRemove = List_new();
	DATA(self)->events = List_new();
	DATA(self)->activeEvents = List_new();
	DATA(self)->samplesPerBuffer = FRAMES_PER_BUFFER;
	DATA(self)->volume = 1.0;
	
	DATA(self)->ioBuffer = IoSeq_new(IOSTATE);
	DATA(self)->buffer = IoSeq_rawUArray(DATA(self)->ioBuffer);
	DATA(self)->mixBuffer = UArray_new();
	DATA(self)->writeMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("write"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->writeMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->nonBlockingWriteMessage = 
		IoMessage_newWithName_label_(IOSTATE, 
							    IOSYMBOL("nonBlockingWrite"), 
							    IOSYMBOL("AudioMixer"));
	IoMessage_setCachedArg_to_(DATA(self)->nonBlockingWriteMessage, 0, DATA(self)->ioBuffer);
	
	DATA(self)->soundTouch = SoundTouch_init();
	SoundTouch_setSampleRate(DATA(self)->soundTouch, 44100);
	SoundTouch_setChannels(DATA(self)->soundTouch, 2);
	DATA(self)->tempo = 1.0;
	
	IoState_registerProtoWithId_(state, self, protoId);
	
	{
		IoMethodTable methodTable[] = {
		{"start", IoAudioMixer_start},
		{"stop", IoAudioMixer_stop},
		{"sounds", IoAudioMixer_sounds},
		{"addSound", IoAudioMixer_addSound_},
		{"addSoundOnSampleOfSound", 
			IoAudioMixer_addSound_onSample_ofSound_},
		{"removeSound", IoAudioMixer_removeSound_},
		{"removeAllSounds", IoAudioMixer_removeAllSounds},
		{"removeSoundOnSampleOfSound", IoAudioMixer_removeSound_onSample_ofSound_},
		{"setSamplesPerBuffer", IoAudioMixer_setSamplesPerBuffer},
		{"setVolume", IoAudioMixer_setVolume},
		{"setTempo", IoAudioMixer_setTempo},
		{"setSampleRate", IoAudioMixer_setSampleRate},
		{"setPitchSemiTones", IoAudioMixer_setPitchSemiTones},
		{"setAudioDevice", IoAudioMixer_setAudioDevice},
		{NULL, NULL},
		};
		IoObject_addMethodTable_(self, methodTable);
	}
	
	DATA(self)->ioAudioDevice = IoObject_rawGetSlot_(self, IOSYMBOL("AudioDevice"));
	{
		IoMessage *m = 0x0;
		IOASSERT(DATA(self)->ioAudioDevice, "unable to find AudioDevice");
	}
	return self;
}