Re: non audio Buffer contents to a file

View: New views
2 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: non audio Buffer contents to a file

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Actually it isn't the right list.... this is the right one:
sc-users@...

The create.ucsb lists, while still running, are no longer maintained
or archived. All sc-users emails should go to the bham.ac.uk address.
hjh

On Tue, Jul 15, 2008 at 10:50 AM, nescivi <nescivi@...> wrote:

> Hiho,
>
> On Tuesday 15 July 2008 10:43:29 lea nicholson wrote:
>> I had a question on here a couple of weeks ago about recording mouse
>> movements to a buffer. The help provided was incredibly useful. I am
>> now trying to record the content of that buffer to a file, and running
>> into some problems there.
>>
>> as far as I understand it,
>>
>> Buffer.write
>>
>> is expecting to be writing to a sound file, and requires appropriate
>> info for this task. This is not what I am doing here. Obviously, I
>> tried this and it didn't work, but no surprise. So I went up the chain
>> a little to
>>
>> File.write
>>
>> This seemed a great deal more promising. However, the following code
>> doesn't work, and I am not sure why, given that Buffers are described
>> as "globally available arrays of floats" in help file for Buffer.
>>
>> // This block should record buffer b - containing mouse movement data
>> - to a file?
>> (
>> var h;
>> // "wb" arg for read/write binary
>> h = File("myFile", "wb");
>> // b is buffer containing mouse movement coords
>> b.do({ arg item; h.putFloat(item)});
>> h.close;
>> )
>>
>> error message starts
>>
>>       ERROR: Primitive '_FilePutFloat' failed.
>>       Wrong type.
>>
>> running b as a line of code gives:
>>
>>       Buffer(2, 10335.9375, 1, 44100, nil)
>>
>> so the Buffer does exist.
>>
>> Also, is this question appropriate for this list - a great deal of the
>> questions on here seem to be concerned with development?
>
> this is the right list.
>
> Buffer in the language (sclang) is a representation of a buffer on the server
> (scsynth).
> If you want to write the contents to a file, you either have to use Buffer's
> write method and not care so much that the file will have an audio header (or
> use the format "raw", which will result in a raw binary file, which seems to
> be what you want anyway), or retrieve the data from the buffer to the
> language (with Buffer.getToFloatArray) and store it with File.
>
> sincerely,
> Marije
> _______________________________________________
> sc-users mailing list
> sc-users@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>



--
James Harkins /// dewdrop world
jamshark70@...
http://www.dewdrop-world.net

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal." -- Whitman

_______________________________________________
sc-users mailing list

info (subscribe and unsubscribe): http://swiki.hfbk-hamburg.de:8888/MusicTechnology/880
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/

Parent Message unknown Re: non audio Buffer contents to a file

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi -

Attached is an extension I made to write Buffer or Array data as CSV
text files. Save the file into your SC extensions folder and restart
SC, then you should be able to run

b.writeCSV("/test-buffer-data.csv")

Maybe useful

Dan



2008/7/15, lea nicholson <lea@...>:

> Hi,
>
> I had a question on here a couple of weeks ago about recording mouse
> movements to a buffer. The help provided was incredibly useful. I am now
> trying to record the content of that buffer to a file, and running into some
> problems there.
>
> as far as I understand it,
>
> Buffer.write
>
> is expecting to be writing to a sound file, and requires appropriate info
> for this task. This is not what I am doing here. Obviously, I tried this and
> it didn't work, but no surprise. So I went up the chain a little to
>
> File.write
>
> This seemed a great deal more promising. However, the following code doesn't
> work, and I am not sure why, given that Buffers are described as "globally
> available arrays of floats" in help file for Buffer.
>
>
> // This block should record buffer b - containing mouse movement data - to a
> file?
> (
> var h;
> // "wb" arg for read/write binary
> h = File("myFile", "wb");
> // b is buffer containing mouse movement coords
> b.do({ arg item; h.putFloat(item)});
> h.close;
> )
>
> error message starts
>
>
>  ERROR: Primitive '_FilePutFloat' failed.
>  Wrong type.
>
> running b as a line of code gives:
>
>
>  Buffer(2, 10335.9375, 1, 44100, nil)
>
> so the Buffer does exist.
>
> Also, is this question appropriate for this list - a great deal of the
> questions on here seem to be concerned with development?
>
> Thanks
>
> Lea Nicholson
>
>
>
>
> _______________________________________________
>  sc-users mailing list
>  sc-users@...
>  http://lists.create.ucsb.edu/mailman/listinfo/sc-users
>
>

--
http://www.mcld.co.uk


writeCSV.sc (1K) Download Attachment
LightInTheBox - Buy quality products at wholesale price