# getStateInformation & parameters as binary data?

**URL:** <https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089>\
**Category:** Audio Plugins\
**Created:** [July 9, 2009, 5:29pm UTC](https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089 "2009-07-09T17:29:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Salvator](https://avatars.discourse-cdn.com/v4/letter/s/51bf81/32.png) [@Salvator](https://forum.juce.com/u/Salvator)\
**Post date:** [July 9, 2009, 5:29pm UTC](https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089/1 "2009-07-09T17:29:26Z")

</div>

Hello,

The Juce Demo plugin use xml stuff for storing/retreiving parameters,but I’m trying to storing/retreive parameters as 32b floats straight in the binary data from getStateInformation().

I need this because I plan to update one of my old plugin with a Juce version, and want to keep recall of the parameters…

What’s the best way for doing so ?

I see that AU lab store the setting of my old plugins as hexadecimal representation of float. In a manner that 1.0 is represented by 3F800000.

As far juce, I understand that the xml stuff convert the float value to a string, that is variable size because of UTF-8, then write an hex representation of the string ?

So I’ve tried to write a float value of my parameter (gain) straight into the binary memory :

destData.copyFrom (&gain, 0, 4);

Now it allow me to get a fixed size + hexadecimal representation of my float, BUT it’s stored in little-endian way so that 1.0 make 0000803F.

At this point I’m guessing, should I just start trying to swap the byte order (but swapByteOrder is for int only, not float ?), or am I going totally in a wrong direction ?

Any helping advice would be very appreciated.

Thanks,

Salvator

---

<div class="post-metadata">

**Author:** ![swar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/swar/32/12935_2.png) [@swar](https://forum.juce.com/u/swar)\
**Post date:** [May 2, 2024, 2:25pm UTC](https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089/2 "2024-05-02T14:25:19Z")

</div>

Bump.

Is there a JUCE function to convert 4 memory bytes into a float, like this tool: [Floating Point to Hex Converter](https://gregstoll.com/~gregstoll/floattohex/)

---

<div class="post-metadata">

**Author:** ![eyalamir](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/eyalamir/32/2978_2.png) [@eyalamir](https://forum.juce.com/u/eyalamir)\
**Post date:** [May 2, 2024, 5:52pm UTC](https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089/3 "2024-05-02T17:52:42Z")

</div>

Read the code for juce::InputStream which you can construct from the data given to you in getState (technically you would construct a MemoryInputStream).

The Input stream lets you read the data any way way you like, using methods like readFloat(), readFloatBigEndian(), etc.

---

<div class="post-metadata">

**Author:** ![swar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/swar/32/12935_2.png) [@swar](https://forum.juce.com/u/swar)\
**Post date:** [May 2, 2024, 6:52pm UTC](https://forum.juce.com/t/getstateinformation-parameters-as-binary-data/4089/4 "2024-05-02T18:52:41Z")

</div>

Awesome! Works like a charm. Thanks a lot for the help!
