SunVox Library - sv_set_pattern_data is not exported, or does not exist [not a bug]

Found a bug? Post it here.
Post Reply
User avatar
Sotakebk
Posts: 16
Joined: Thu Nov 03, 2022 8:52 pm

SunVox Library - sv_set_pattern_data is not exported, or does not exist [not a bug]

Post by Sotakebk »

As in the title, while listed in the documentation, the library does not export the function.
"sv_set_pattern_event" must be used instead, which can be slow if I have to iterate over large chunks of data.
Last edited by Sotakebk on Fri Feb 03, 2023 1:04 am, edited 1 time in total.
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Library - sv_set_pattern_data is not exported, or does not exist

Post by NightRadio »

set_pattern_data() is only for Java (as mentioned in documentation).
In other systems you can use get_pattern_data() for both reading and writing, because it returns a pointer to RW block of memory.
But as far as I understand, in the context of C# there may be problems with this pointer. Or not?
User avatar
Sotakebk
Posts: 16
Joined: Thu Nov 03, 2022 8:52 pm

Re: SunVox Library - sv_set_pattern_data is not exported, or does not exist

Post by Sotakebk »

because it returns a pointer to RW block of memory
Wow, do I feel silly now.
But as far as I understand, in the context of C# there may be problems with this pointer. Or not?
Not at all, it somehow just slipped my mind that it could be asynchronously read/writable like that. I guess I'll get it done that way.
Can't it be a footgun, though? Any unexpected behaviour that could happen when not doing it in a lock() unlock() block?
User avatar
NightRadio
Site Admin
Posts: 3944
Joined: Fri Jan 23, 2004 12:28 am
Location: Ekaterinburg. Russia
Contact:

Re: SunVox Library - sv_set_pattern_data is not exported, or does not exist

Post by NightRadio »

Can't it be a footgun, though? Any unexpected behaviour that could happen when not doing it in a lock() unlock() block?
You must call get_pattern_data() every time something changes the size of the pattern. There shouldn't be any other pitfalls, especially if everything is done in one thread.
In multithreaded code, a rare conflict can occur when reading and writing the same line of the pattern at the same time. As a result, for example, a note may hang. To avoid this, wrap the pattern change code with lock()/unlock()
Post Reply