Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfz~ fix load scalastring #1684

Closed
porres opened this issue Jul 9, 2023 · 13 comments
Closed

sfz~ fix load scalastring #1684

porres opened this issue Jul 9, 2023 · 13 comments

Comments

@porres
Copy link
Owner

porres commented Jul 9, 2023

There's code copied from ceammc's sfizz~ that doesn't work. All we need is a string into a built in sfizz_load_scala_string function. The string is tuning name, number of steps and steps in cents in this format "weird\n4\n155\n555\n777\n1111\n"

So I am trying to build this string from a list of intervals in cents and it is failing, but trying the string above works! The code from ceammc's sfizz~ uses this structure below and if I print the string in the code I do get something that looks exactly like a string that gets accepted, but trying to build this string this way fails somehow (while it must work for ceammc maybe, haven't tested)

char scale[2048] = "autogenerated scale\n";

char* pscale = &scale[0] + strlen(scale);

pscale += sprintf(pscale, "%d\n", ac);

for(int i = 1; i < ac; i++)

    pscale += sprintf(pscale, "%f\n", atom_getfloat(av+i));

see https://github.com/porres/pd-else/blob/master/sfizz~/sfizz_puredata.c#L107

@sebshader
Copy link
Contributor

sebshader commented Jul 9, 2023

have you tried adding an additional backslash character before the \ns in the sprintfs?

also what does 'fails somehow' mean? where exactly does it fail? edit: oh I see, you try to load it and it fails

it would also help if you point to the original file you're working from on github

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

it would also help if you point to the original file you're working from on github

https://github.com/uliss/pure-data/blob/d627d8775a5655555b36d58ee0cf810b655cc215/ceammc/ext/src/misc/sfizz_tilde.cpp#L531

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

have you tried adding an additional backslash character before the \ns in the sprintfs?

didnt see why it'd work and it didn't :/

@sebshader
Copy link
Contributor

@porres yeah idk thought it might be some weird escaping thing the file format expected or something.

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

by the way "weird\n4\n155\n555\n777\n1111" also works (without ending with "\n")

@sebshader
Copy link
Contributor

does it work with "weird\n4\n155.0\n555.0\n777.0\n1111.0"?

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

good question, it actually works even better!

@sebshader
Copy link
Contributor

sebshader commented Jul 10, 2023

sorry I'm not on my dev computer rn, what message do you test it with that it fails with?
edit: to me it looks like the for should start at int i = 0

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

to me it looks like the for should start at int i = 0

It should maybe, but it doesn't, the way I specify scales in cents is that it always starts with "0" cents and this firs one needs to be ignored. Anyway, it's intentional

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

i think i see the issue now

@porres porres closed this as completed Jul 10, 2023
@porres
Copy link
Owner Author

porres commented Jul 10, 2023

the number of steps in the scale was 1 too many higher :) thanks!

@eeropic
Copy link

eeropic commented Jul 10, 2023

to me it looks like the for should start at int i = 0

It should maybe, but it doesn't, the way I specify scales in cents is that it always starts with "0" cents and this firs one needs to be ignored. Anyway, it's intentional

Should you -1 from ac?

@porres
Copy link
Owner Author

porres commented Jul 10, 2023

exactly, that fixed it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants