Started porting fiddle~ and bonk~ to Max7 Windows 64 bit

alfonso santimone's icon

Hi guys,
original fiddle~ code is from 1999 so i guess it uses old Max/MSP conventions.
I've managed to compile it with Visual Studio 2013 for x64 architecture ( fiddle~.mxe64).
I have this yellow marked warning in the Max7 window when i create the object.
"fiddle~ . msp object need to be updated for msp64".
I'm a Max SDK newbie so it is pretty difficult to restructure the code..but i guess that is nothing more than some smart moves.
Can anybody help me?
Or just give me some hint?

thanks

do.while's icon

Hi !
In your "~" case it might be that your DSP methods are written in old SDK style . You should read "Anatomy Of a MSP Object" section in SDK doc against your legacy code . Otherwise let us see the code

alfonso santimone's icon

Hi guys,
i'm trying to restructure the code to adapt to the new SDK standards.
In case of fail i'll look for your help again (i want to port bonk~ too...and i.e. among other not workin' things there's a "OSType" type that's not defined in any Windows library neither in the Max SDK libs.)

in the meantime many thanks and surely i'll be back for some help :-)

Peter Castine's icon

OSType was #defined to 'unsigned long'. The data type was used extensively in Classic Mac OS for file metadata for things like identifying file type and specifying the application to open the file with by default; and there was a convention that you could specify the value by a string of four ASCII chars (a convenient mnemonic in many cases). The entire convention was phased out in the course of Mac OS X, and was only ever used on Windows to approximate Mac OS behavior..

You can simply make your own #define for this, but you can probably get rid of all variables in legacy code that use the data type. (The latter approach may take more effort, though.)

alfonso santimone's icon

Thank Peter!
i just did a#define OSType unsigned long

and i get rid of those errors.

Regarding fiddle~ i'm takin' the occasion to better learn MaxSDK, and i'm still trying to follow the challenge to try to restructure the code for "modern" standards. If i won't get success i'll ask again for help!

Now i'm trying to compile bonk~ to (and the next will be sigmund~)
Now i have only one error and a bunch of warnings.
Error 10 is relative to this linegp->g_invec = (*(sp++))->s_vec;
Error 10 error C4133: ‘=’ : incompatible types – from ‘t_sample *’ to ‘t_float *’ C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c 514 1 bonk~

And a bunch of warnings (those about data loss i guess aren't so important)

bonk~ code attached as a zip file

Warning    1    warning C4005: 'getbytes' : macro redefinition    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    47    1    bonk~
Warning    2    warning C4005: 'freebytes' : macro redefinition    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    48    1    bonk~
Warning    3    warning C4305: 'initializing' : truncation from 'double' to 'float'    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    93    1    bonk~
Warning    4    warning C4305: '=' : truncation from 'double' to 'float'    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    218    1    bonk~
Warning    5    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    250    1    bonk~
Warning    6    warning C4244: '*=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    257    1    bonk~
Warning    7    warning C4305: '=' : truncation from 'double' to 'float'    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    289    1    bonk~
Warning    8    warning C4305: 'initializing' : truncation from 'double' to 'float'    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    325    1    bonk~
Warning    9    warning C4244: '+=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    428    1    bonk~
Error    10    error C4133: '=' : incompatible types - from 't_sample *' to 't_float *'    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    514    1    bonk~
Warning    11    warning C4244: '=' : conversion from 't_floatarg' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    524    1    bonk~
Warning    12    warning C4244: '=' : conversion from 't_floatarg' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    525    1    bonk~
Warning    13    warning C4244: 'initializing' : conversion from 't_floatarg' to 'int', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    530    1    bonk~
Warning    14    warning C4244: '=' : conversion from 't_floatarg' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    535    1    bonk~
Warning    15    warning C4244: '=' : conversion from 't_floatarg' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    542    1    bonk~
Warning    16    warning C4244: '=' : conversion from 't_floatarg' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    548    1    bonk~
Warning    17    warning C4244: 'initializing' : conversion from 't_floatarg' to 'int', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    601    1    bonk~
Warning    18    warning C4244: 'initializing' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    667    1    bonk~
Warning    19    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    668    1    bonk~
Warning    20    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    669    1    bonk~
Warning    21    warning C4244: '=' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    673    1    bonk~
Warning    22    warning C4996: 'Atom': was declared deprecated    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    885    1    bonk~
Warning    23    warning C4996: 'Atom': was declared deprecated    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    905    1    bonk~
Warning    24    warning C4026: function declared with formal parameter list    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    1031    1    bonk~
Warning    25    warning C4028: formal parameter 1 different from declaration    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    1032    1    bonk~
Warning    26    warning C4013: 'rescopy' undefined; assuming extern returning int    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    1049    1    bonk~
Warning    27    warning C4244: 'return' : conversion from 'double' to 'float', possible loss of data    C:\SDKs\max-sdk-7.0.3\source\audio\bonk~\bonk~.c    1073    1    bonk~

bonk.zip
zip
do.while's icon

Hi !
What Raja suggest is the key here . If u want to compile it under 64bit u have to convert datatypes .t_sample in your t_signal is a double value at 64bit mode . All the other complainings are of the same nature :/ lot of work . also new style DSP setup would be easier to maintain than dealing with vectors as bonk did years back .

#edit
using t_sample for the vector related stuff will stay compatible in 32bit and 64bit mode . as this type has two mode definitions (float at 32bit / double at 64bit) .
Audio itself stays always at float type (t_float) .

alfonso santimone's icon

Hi @DO...WHILE!
i'll try to restructure the code...but i guess i'll need some time studying the SDK as it's needed ! :-)
I think there are a lot of interesting Mac only externals (or Win 32 only, or old 32bit maxmsp style) and i like to port some to Win 64 too.
best!

alfonso santimone's icon

so do you think that translating all the vector related stuff to t_sample would be the right move? ( but then i'll have to do the new t_perform64 and add_dsp64 stuff)

do.while's icon

yes Alfonso (unless im dump) . im encouraging you to move into the new dsp64 all the way though . This way u write for both 32/64 .

do.while's icon

as i said . t_sample is double at 64bit and float at 32bit . so it wont complain while compiling to both modes

Emmanuel Jourdan's icon

On the other hand, if you are doing something with the audio signal , it's probably best to keep everything in double. This will still be compatible with 32/64 bits architecture and you don't loose precision for your DSP calculation. How about posting the code on github or something so people can help you / share / comment?

alfonso santimone's icon

Thanks EMMANUEL, i'll post on github tomorrow!

i'll surely need some little help :-)

alfonso santimone's icon

here's fiddle~
the code is based on old MaxMSP SDK.
My limited knowledge of Max SDK is based on Eric Lyon great book.
It's kind of difficult to me to translate that code to new standards.
So i'm lookink for suggestions and help to point me in the right direction.

Uploading bonk~ to GitHub in a while...

alfonso santimone's icon
alfonso santimone's icon

Thank RAJA!
Yes i got that doc.
The thing is that seems pretty difficult to understand the old fiddle~ code.
Eric's doc is relative to the transition from Max5 to Max6. But fiddle~ code is way older than Max5 era.
I'll try to find my way through :-)

But basicaly i really don't understand the dsp cycle.
It's not the while(n--) loop but a for loop that uses two different variables,
and then there's the if statement wich skip the dsp loop if the object is muted.
But i guess is an old way to do it.
static t_int *fiddle_perform(t_int *w)
{
t_double *in = (t_double *)(w[1]);
t_sigfiddle *x = (t_sigfiddle *)(w[2]);
int n = (int)(w[3]);
int count,inc = x->x_downsample;
float *fp;

if (x->x_obj.z_disabled)
    goto skip;
for (count = 0, fp = x->x_inbuf + x->x_phase; count < n; count+=inc) {
    *fp++ = *in;
    in += inc;
}
if (fp == x->x_inbuf + x->x_hop)
{
        sigfiddle_doit(x);
        x->x_phase = 0;
        if (x->x_auto) clock_delay(x->x_clock, 0L);
        if (x->x_nprint) x->x_nprint--;
}
else x->x_phase += n;
skip:
return (w+4);
}

void sigfiddle_dsp(t_sigfiddle *x, t_signal **sp)
{
    x->x_sr = sp[0]->s_sr;        /* adding for MSP2 compatibility */
if (sp[0]->s_n > x->x_hop) {
    x->x_downsample = sp[0]->s_n / x->x_hop;
    post("* warning: fiddle~: will downsample input by %ld",x->x_downsample);
    x->x_sr = sp[0]->s_sr / x->x_downsample;
} else {
    x->x_downsample = 1;
        x->x_sr = sp[0]->s_sr;
    }
    sigfiddle_reattack(x, x->x_attacktime, x->x_attackthresh);
sigfiddle_vibrato(x, x->x_vibtime, x->x_vibdepth);
dsp_add(fiddle_perform, 3, sp[0]->s_vec, x, sp[0]->s_n);
}

Florent Ghys's icon

Thanks so much Alfonso for doing that.
I absolutely have no idea about what you guys are talking about, but I'd be happy to be able to use fiddle~ and bonk~ in 64bits.
Is there a compiled version that's working?
thanks

alfonso santimone's icon

many thanks Raja and all other, i hope to get some news by the end of Summer.
best!

Andrea's icon

Don't mean to revive dead topics, but i hope the project is still going on!

As Florent said, I’d be happy to be able to use fiddle~ and bonk~ in 64bits.

Florent Ghys's icon

hey Andrea, did you check out retune~? it's pretty awesome

Andrea's icon

Ah darn, thanks for the tip! Will definitely check that out

Karl Ronneburg's icon

I would love to see bonk~ for max 7 64-bit as soon as possible!

Florent Ghys's icon

any news on that front? I miss fiddle~!

Music_SDP's icon

Has anyone had any luck with completing this? It's my only 32-bit holdover these days and I'd love to see fiddle~ ported. I know retune~ exists, but I've found that using retune~ with fiddle~ gets even better results...

pdelges's icon

Hi again Skryabin,

So now you know what kind of problem switching to 64 bit mode can bring :-)
You can find fiddle~ here: https://github.com/v7b1/fiddle_64bit_version/releases

p

alfonso santimone's icon

Hi guys, anyway i compiled sigmund~.mxe64 bonk~.mxe64 and fiddle~.mxe64.
If anybody needs thos i can upload a zip here.
best

deligut's icon

I would actually be interested. Could you upload those 3? Thanks for your help.

alfonso santimone's icon

here they are
best

fiddle_bonk_sigmund_Win32_Win64_Max7.zip
zip
vichug's icon

guys you're wonderful !

deligut's icon

Thanks a lot for sharing. Great stuff.

alfonso santimone's icon

thanks to volker bohm! he ported the old version to new SDK format!
i just compiled for win.
http://vboehm.net/downloads/