ΣSigmaStudio Ask AI Русский Log in

8_24 conversion

SigmaDSP & SigmaStudio Alez_22 Jan 29, 2020 00:00 3 replies Original on forum ↗
Thread Summary

Thread Summary

The user asked about the definition and usage of SIGMASTUDIOTYPE_8_24_CONVERT. The final answer clarified that the macro definition provided in the accompanying answer is incorrect due to operator precedence, causing a compile error. A corrected definition is #define SIGMASTUDIOTYPE_8_24_CONVERT(x) ((int32_t)((x)*0x1000000)), which is equivalent to the intended (x)*0x01 AI Generated Content
Subscribe
Alez_22 Question
Jan 29, 2020 00:00

Hi,

I have a doubt,

I would like to know how and where SIGMASTUDIOTYPE_8_24_CONVERT is defined.

Anyone can help me?

Thnaks in advance

8.24

8_24

micronctroller

SigmaDSP

matthijs Reply
Jan 29, 2020 00:00

It doesn't seem to be defined anywhere, but a suitable definition would presumably be:

#define SIGMASTUDIOTYPE_8_24_CONVERT(x) ((int32_t)((x)*0x1000000))

Alez_22 Reply
Jan 30, 2020 00:00

I suppose that actually is:

#define SIGMASTUDIOTYPE_8_24_CONVERT(x) ((int32_t)((x)* 0x01 << 24))

But the real question is whether I can use it in my own code or I have to define an equivalent mine.

matthijs Reply
Feb 1, 2020 00:00

Oh, that seems to be missing in the export files I checked (which were just some random old export I had sitting around).

That definition is actually wrong though due to operator precedence, and will result in a compile error if you try to use a constant that uses the macro if defined like that:

test.c:2:62: error: invalid operands to binary << (have ‘double’ and ‘int’)
2 | #define SIGMASTUDIOTYPE_8_24_CONVERT(x) ((int32_t)((x)* 0x01 << 24))
| ~~~~~~~~~ ^~
| |
| double

It needs parentheses around the "0x01 << 24", at which point it's 100% equivalent to the definition I gave (except I just wrote 0x1000000 instead of 1 << 24).

I'm not sure what you mean by your question.