electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
go to the radio page Live at electro-music.com radio 1 Please visit the chat
  host / artist show at your time
today> Twyndyllyngs Live Chez Mosc
 Forum index » DIY Hardware and Software » ChucK programming language
file IO with OSC
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
hanez



Joined: Feb 07, 2007
Posts: 10
Location: Austria

PostPosted: Mon Oct 22, 2007 6:15 am    Post subject: file IO with OSC
Subject description: a small utility program that allows file input/output from within chuck using OSC
Reply with quote  Mark this post and the followings unread

hello,

recently i was doing some "chuck research" using the new UAna's. the goal was to develop an audio-to-midi translator to trigger my synths with the microphone (my voice). Just for the chucking fun of it. I used the spectral flux for note-on detection, but at the beginning i had no idea how the spectral flux of may voice looked like, i.e. when i bellow a bass line into the mic. So i was confronted with the problem to get the spectral flux data out of chuck to analyse it with a different program (i use matlab for this). as far as i know there is still no file input/output functionality in chuck.
That's why i coded (in C++, using MS Visual Studio 2005, release build) a small utility that can receive data from chuck and save it into a ASCII textfile and it also can load such a file and send it to chuck using the OSC protocol. So with it you can analyse (plot, make calculations with it, show it your girlfriend) data generated by chuck, you can make a preset management for your chuckmachines and you can feed them with external data.
I thought, i will share this here, because maybe some other chuckchuckers also needs this functionality. So here it is. WinXP only, sorry.
Download it, read the readme, test it with the two examples "testInput.ck", "testOutput.ck". You have to adapt these two files, read the comments.
I also included the source code for those who want to improve it. To do so you also need the oscpack library, described in the readme.
(I don't know if there are additional microsoft-specific dll's (msvcrt.dll?) or other files necessary to run the .exe. If so they should be available on the net).
Of course, if this chucky software chucks down your computer into chuckhell - i take no chucking responsibility.

chucks,
hanez


oscFileIO.zip
 Description:
utility for file IO

Download (listen)
 Filename:  oscFileIO.zip
 Filesize:  22.56 KB
 Downloaded:  330 Time(s)

Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Oct 22, 2007 9:45 pm    Post subject: Reply with quote  Mark this post and the followings unread

Oh.. wow! thanks for this valuable contribution, i hope this can grow into a very useful tool for various applications someday!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
chuckles



Joined: Apr 02, 2007
Posts: 72
Location: San Diego, California

PostPosted: Wed Oct 24, 2007 12:12 pm    Post subject: Reply with quote  Mark this post and the followings unread

I haven't tried it yet (my main music machine is still running Windows 2000, believe it or not) but I just wanted to come in and really encourage this kind of work.

I have ideas for chuck that need the orchestra/score separation a la Csound (and other MusicN languages) where I can create a single orchestra and feed it all kinds of different data files (perhaps even MIDI, eventually) to create different pieces with given sound generation algorithms. So this is exciting to me even if I have to plug in some other libraries/dlls.
Back to top
View user's profile Send private message
Inventor
Stream Operator


Joined: Oct 13, 2007
Posts: 6221
Location: near Austin, Tx, USA
Audio files: 267

PostPosted: Wed Oct 24, 2007 7:13 pm    Post subject: Reply with quote  Mark this post and the followings unread

I would use your contribution to send out the text that generates POV-Ray animations if it ran on a Mac. Maybe the ChucK developers can plug your code into ChucK to add the functionality. Anyway it is nice to see the contributions and collaborations that are happening here.
Back to top
View user's profile Send private message Send e-mail
hanez



Joined: Feb 07, 2007
Posts: 10
Location: Austria

PostPosted: Thu Oct 25, 2007 12:06 am    Post subject: Reply with quote  Mark this post and the followings unread

chuckles wrote:
I haven't tried it yet (my main music machine is still running Windows 2000, believe it or not) but I just wanted to come in and really encourage this kind of work.


hi,

i tested it also on an win2000 machine, and it worked.

greetz
hanez
Back to top
View user's profile Send private message
eduard



Joined: Nov 04, 2007
Posts: 2
Location: Barcelona

PostPosted: Mon Nov 05, 2007 1:12 am    Post subject: makefile for oscTofile
Subject description: makefile for oscTofile
Reply with quote  Mark this post and the followings unread

Here's a makefile for compiling fileToOsc on unixes like OS.
You should create a directory called src where you should put the oscToFile* files and another for oscpack.
However when run on OS X I get the following error ( i think there should be easier test examples so the problem is easier to track):

In one terminal I run: oscToFile 9000 while in another terminal I run chuck testInput.ck testOutput.ck.
The output in terminal 1 is:
listening for input on port 9000...
press ctrl-c to end
/oscFromFile
fileName: sinusParam.dat
formatString: sf
hostToSend: localhost
portToSend: 1092550656
bufsize: 262144
terminate called after throwing an instance of 'std::runtime_error'
what(): unable to connect udp socket

Abort trap


The output in the terminal 2:
[chuck](VM): removing shred: 3 (spork~exp)...
values: 0.000000 0.000000


Here's the makefile:

PROGRAM = osc2File
CXX = g++
ENDIANESS=OSC_HOST_BIG_ENDIAN
CXX_FLAGS = -g -Wall -D$(ENDIANESS)
OSC_DIR=./oscpack
INCLUDE= -I$(OSC_DIR)
SRC_DIR = src
SRC_FILES= $(SRC_DIR)/oscToFile.cpp $(OSC_DIR)/osc/OscTypes.cpp\
$(OSC_DIR)/osc/OscReceivedElements.cpp $(OSC_DIR)/osc/OscPrintReceivedElements.cpp\
$(OSC_DIR)/osc/OscOutboundPacketStream.cpp $(OSC_DIR)/ip/posix/NetworkingUtils.cpp\
$(OSC_DIR)/ip/posix/UdpSocket.cpp $(OSC_DIR)/ip/IpEndpointName.cpp

OBJS = $(SRC_FILES:.cpp=.o)

all: $(PROGRAM) $(OBJS)

$(PROGRAM): $(OBJS)
$(CXX) $(CXX_FLAGS) $(INCLUDE) -o $(PROGRAM) $(SRC_DIR)/oscToFileMain.cpp $(OBJS)

.cpp.o:
$(CXX) -c $(CXX_FLAGS) $(INCLUDE) -o "$@" "$<"


clean:
-rm $(OBJS)

distclean: clean
-rm $(PROGRAM)
Back to top
View user's profile Send private message
eduard



Joined: Nov 04, 2007
Posts: 2
Location: Barcelona

PostPosted: Mon Nov 05, 2007 4:02 am    Post subject: makefile for oscToFile (found the problem)
Subject description: makefile for oscToFile (found the problem)
Reply with quote  Mark this post and the followings unread

There was a problem with the endianess. I had declared it as BIG_ENDIAN but I'm on a LITTLE_ENDIAN machine.
So if you are on a Unix like system you may want to try it out.


oscToFile.zip
 Description:

Download (listen)
 Filename:  oscToFile.zip
 Filesize:  87.46 KB
 Downloaded:  310 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use