Skip to content

Fixes issue with wrong numbers printing to console in csound for iOS #97

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jase5
Copy link

@jase5 jase5 commented Aug 19, 2024

I was running into issues when using the supplied code snippet for printing to the Xcode console from iOS using swift. Most numbers were completely off, usually extremely high or negative.
It seems like the extra step for creating a CVaListPointer was messing something (not sure what) up. However, when just using info.valist directly, this works. As I do not exactly understand why this extra code was there, somebody who knows should check if my change is breaking something that I am unaware of! As I understand it, the valist in the csound message is already compatible with vsnprintf().
I deleted the corresponding mention of the now deleted extra code in the manual text, too.

… iOS

I was running into issues when using the supplied code snippet for printing to the Xcode console from iOS using swift. It seems like the extra step for creating a CVaListPointer was messing something (not sure what) up. However, when just using info.valist directly, this works. 
As I do not exactly understand why this extra code was there, somebody who knows should check if my change is breaking something.
I deleted the corresponding mention of the now deleted extra code in the manual text, too.
)
vsnprintf(message, 1024, info.format, va_ptr)

vsnprintf(message, 1024, info.format, info.valist)
let messageStr = String(cString: message)
print(messageStr)
Copy link
Author

@jase5 jase5 Sep 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the memory for buffer should be deallocated in the end to prevent excessive memory use:
message?.deallocate()

@jase5
Copy link
Author

jase5 commented Sep 28, 2024

A similar fix was approved here: nikhilsinghmus/CsoundiOS_SwiftExamples#1

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

Successfully merging this pull request may close these issues.

1 participant