[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-dev] SynthDesc from SynthDef.asBytes. converting byte arrays to int16 and floats



Thanks, that is actually what I was asking for. 
Except for the getFloat.  At this point, I'd need to 
code this in SC (rather than in C++). What is the algorithm
for this? 

IZ

-------------------

On Fri, 6 Aug 2004, James McCartney wrote:

> 
> This is not the best approach. You should implement the methods in 
> CollStream like this.
> 
> 	getChar { ^this.next; }
> 	getInt8 { ^this.next & 255; }
> 	getInt16 { ^this.getInt8 << 8 | this.getInt8; }
> 	getInt32 { ^this.getInt16 << 16 | this.getInt16; }
> 	getFloat { ^Float.from32bits(this.getInt32); }
> 	getDouble { ^Float.from64bits(this.getInt32, this.getInt32); }
> 	getPascalString {
> 		var size, string;
> 		size = this.getInt8;
> 		string = String.newClear(size);
> 		size.do {|i| string[i] = this.getChar };
> 		^string
> 	}
> 
> unfortunately there is nothing like Float.from32bits or 
> Float.from64bits. There should be primitives for that.
> 
> 
> On Aug 6, 2004, at 3:47 PM, Ioannis Zannos wrote:
> 
> >
> > Hello,
> > I am trying to add a method SynthDesc-fromSynthDefBytes, so as to
> > be able to create a SynthDesc directly from SynthDef without having
> > to load it from its data on Unix file.  This would be very
> > useful for creating synthdescs and accompanying GUIs for playing
> > functions on-the-fly.   Could someone help me convert from the
> > byte-array format of compiled SynthDefs to SynthDesc by providing
> > a description of the Integer16 and Float formats used in SynthDef
> > files?
> >
> > Below is the framework of the class I am writing that will make the
> > conversion.
> >
> > Thanks.
> 
> _______________________________________________
> sc-dev mailing list
> sc-dev@xxxxxxxxxxxxxxx
> http://www.create.ucsb.edu/mailman/listinfo/sc-dev
> 

-- 
Iannis Zannos
Research Director
Center for Research in Electronic Art Technology
Music Department / MAT,
University of California, Santa Barbara,
Santa Barbara, California 93106

Tel: (805) 893-8352
Fax: (805) 893-7194

http://www.create.ucsb.edu/~iani/