[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev
Thanks to Sven's tips I fixed the package and ditched the hacky Stream 
class. I also cleaned up some messy parts in the implementation. I 
noticed that the current implementation does not handle blobs and the 
server packet processing logic could be improved. Also, I am not sure 
whether recursive bundles are handled correctly (more test cases needed) 
and to which extent they are used in OSC applications, so one would have 
to do a fair bit of polishing for an "industry grade" implementation.


In any case, if there are any users that would like to use and test OSC, 
I am happy to take feedback and make necessary additions/modifications.


Stef, I'll send you a pull request tomorrow, now I have to catch some 
sleep.


On 5/21/21 6:23 PM, ducasse wrote:

Thanks.
I do not think that it is good to reintroduce this super ugly class. 
at the minimum it should be in a separate branch.


S

On 21 May 2021, at 18:06, Günter Khyo via Pharo-dev 
mailto:pharo-dev@lists.pharo.org>> wrote:


Hi Stef,

Great! I'll send you a pull-request for the "hotfix" this evening. As 
I mentioned to Sven, I'll do some rework on the implementation and 
documentation when I find the time.


Günter

On 5/21/21 5:55 PM, ducasse wrote:

I checked and all the tests pass on Pharo80.
Now I did a little pass on the tests.
I do not have the time to migrate this lib to P9.
But I would accept Pull Requests :)

S.

On 21 May 2021, at 17:46, ducasse > wrote:


The old travis was telling that the code works in 6.1, 7 and 8.0
I added GithubActions for Pharo 80 and I will see.

S

On 21 May 2021, at 17:40, ducasse > wrote:


Hi gunter

I’m maintaining OSC
https://github.com/Ducasse/OSC
and TUIO
https://github.com/Ducasse/TUIO

Please do some PR if something does not work.

S

On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
mailto:pharo-dev@lists.pharo.org>> wrote:


Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since 
the Catalog Browser is marked as legacy, I was wondering how to 
submit the patch. Is there a git repository? I attached the 
fileout to this email in case anybody wants to take a look at the 
package or knows how/where to add it to Pharo 9.0,


Patch Note:

OSC relies on the removed /RWTextOrBinaryStream/ class which has 
very specific behavior that I could not emulate using the 
available stream and codec classes, so I pulled in the class from 
Squeak 5, renamed it to OSCStream and added it to the OSC 
package. This seemed to be the easiest way to do it without 
changing the OSC implementation, but I welcome any suggestions 
for a cleaner solution.


Günter

http://osc.st/>>








Object subclass: #OSCPacket
instanceVariableNames: 'byteStream'
classVariableNames: ''
package: 'OSC-Kernel'!

!OSCPacket methodsFor: 'action' stamp: 'mga 9/17/2006 19:17'!
sendToYourself
self sendTo: NetNameResolver localHostAddress port: 57123! !

!OSCPacket methodsFor: 'action' stamp: 'gk 5/21/2021 22:53'!
sendTo: aByteArray port: aPort 
"Take care, A byte array is not a string.
If you want to send to e.g. '192.168.0.2' 
sendToAddressString: port: instead
But use this one if you want to be fast."
| aSocket |
Socket initializeNetwork.
aSocket := Socket newUDP.
aSocket
sendUDPData: self bytes
toHost: aByteArray
port: aPort;
 close;
 destroy! !

!OSCPacket methodsFor: 'action' stamp: 'mga 9/17/2006 19:17'!
sendToAddressString: anAddressString port: aPort 
self 
sendTo: ((anAddressString findTokens: '.') collect: [:e | e 
asNumber]) 
asByteArray
port: aPort! !


!OSCPacket methodsFor: 'initialization' stamp: 'gk 5/21/2021 22:48'!
initializeFor: somePackets
byteStream := ByteArray new writeStream.
self print: somePackets onOSCStream: byteStream! !


!OSCPacket methodsFor: 'accessing' stamp: 'gk 5/21/2021 22:53'!
oSCSize
^self bytes size! !

!OSCPacket methodsFor: 'accessing' stamp: 'mga 3/16/2005 08:58'!
byteStream
^byteStream! !

!OSCPacket methodsFor: 'accessing' stamp: 'gk 5/21/2021 23:00'!
bytes
^self byteStream contents! !


!OSCPacket methodsFor: 'printing' stamp: 'mga 6/24/2000 14:09'!
print: somePackets onOSCStream: aStream
self subclassResponsibility! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

OSCPacket class
instanceVariableNames: ''!

!OSCPacket class methodsFor: 'access to cache' stamp: 'StephaneDucasse 
9/29/2012 22:59'!
for: somePackets
^ self new initializeFor: somePackets ! !


OSCPacket subclass: #OSCBundle
instanceVariableNames: 'packets'
classVariableNames: ''
package: 'OSC-Kernel'!

!OSCBundle methodsFor: 'printing' stamp: 'StephaneDucasse 9/29/2012 23:02'!
printTimeTagOnOSCStream: aStream

[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev

Sven,

Sounds good! Since you are more experienced, would you like to do the 
changes?


On 5/21/21 6:30 PM, Sven Van Caekenberghe wrote:

I am 100% confident that we can fix this easily (i.e. portability across 7, 8 
or 9), there is not a lot of code and it looks pretty straightforward at first 
sight.


On 21 May 2021, at 18:23, ducasse  wrote:

Thanks.
I do not think that it is good to reintroduce this super ugly class. at the 
minimum it should be in a separate branch.

S


On 21 May 2021, at 18:06, Günter Khyo via Pharo-dev  
wrote:

Hi Stef,

Great! I'll send you a pull-request for the "hotfix" this evening. As I 
mentioned to Sven, I'll do some rework on the implementation and documentation when I 
find the time.

Günter

On 5/21/21 5:55 PM, ducasse wrote:

I checked and all the tests pass on Pharo80.
Now I did a little pass on the tests.
I do not have the time to migrate this lib to P9.
But I would accept Pull Requests :)

S.


On 21 May 2021, at 17:46, ducasse  wrote:

The old travis was telling that the code works in 6.1, 7 and 8.0
I added GithubActions for Pharo 80 and I will see.

S


On 21 May 2021, at 17:40, ducasse  wrote:

Hi gunter

I’m maintaining OSC
https://github.com/Ducasse/OSC
and TUIO
https://github.com/Ducasse/TUIO

Please do some PR if something does not work.

S


On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev  
wrote:

Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
Browser is marked as legacy, I was wondering how to submit the patch. Is there 
a git repository? I attached the fileout to this email in case anybody wants to 
take a look at the package or knows how/where to add it to Pharo 9.0,

Patch Note:

OSC relies on the removed RWTextOrBinaryStream class which has very specific 
behavior that I could not emulate using the available stream and codec classes, 
so I pulled in the class from Squeak 5, renamed it to OSCStream and added it to 
the OSC package. This seemed to be the easiest way to do it without changing 
the OSC implementation, but I welcome any suggestions for a cleaner solution.

Günter




[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Sven Van Caekenberghe
I am 100% confident that we can fix this easily (i.e. portability across 7, 8 
or 9), there is not a lot of code and it looks pretty straightforward at first 
sight.

> On 21 May 2021, at 18:23, ducasse  wrote:
> 
> Thanks. 
> I do not think that it is good to reintroduce this super ugly class. at the 
> minimum it should be in a separate branch. 
> 
> S
> 
>> On 21 May 2021, at 18:06, Günter Khyo via Pharo-dev 
>>  wrote:
>> 
>> Hi Stef,
>> 
>> Great! I'll send you a pull-request for the "hotfix" this evening. As I 
>> mentioned to Sven, I'll do some rework on the implementation and 
>> documentation when I find the time. 
>> 
>> Günter
>> 
>> On 5/21/21 5:55 PM, ducasse wrote:
>>> I checked and all the tests pass on Pharo80. 
>>> Now I did a little pass on the tests. 
>>> I do not have the time to migrate this lib to P9.
>>> But I would accept Pull Requests :)
>>> 
>>> S. 
>>> 
 On 21 May 2021, at 17:46, ducasse  wrote:
 
 The old travis was telling that the code works in 6.1, 7 and 8.0
 I added GithubActions for Pharo 80 and I will see.
 
 S
 
> On 21 May 2021, at 17:40, ducasse  wrote:
> 
> Hi gunter
> 
> I’m maintaining OSC  
> https://github.com/Ducasse/OSC
> and TUIO
> https://github.com/Ducasse/TUIO
> 
> Please do some PR if something does not work. 
> 
> S
> 
>> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>>  wrote:
>> 
>> Hi,
>> 
>> I have ported the Open Sound Control package to Pharo 9.0. Since the 
>> Catalog Browser is marked as legacy, I was wondering how to submit the 
>> patch. Is there a git repository? I attached the fileout to this email 
>> in case anybody wants to take a look at the package or knows how/where 
>> to add it to Pharo 9.0, 
>> 
>> Patch Note:
>> 
>> OSC relies on the removed RWTextOrBinaryStream class which has very 
>> specific behavior that I could not emulate using the available stream 
>> and codec classes, so I pulled in the class from Squeak 5, renamed it to 
>> OSCStream and added it to the OSC package. This seemed to be the easiest 
>> way to do it without changing the OSC implementation, but I welcome any 
>> suggestions for a cleaner solution.
>> 
>> Günter
>> 
>> 
> 
 
>>> 
> 


[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev

Agreed. I'll do the rework and send a pull-request when it's finished.

On 5/21/21 6:23 PM, ducasse wrote:

Thanks.
I do not think that it is good to reintroduce this super ugly class. 
at the minimum it should be in a separate branch.


S

On 21 May 2021, at 18:06, Günter Khyo via Pharo-dev 
mailto:pharo-dev@lists.pharo.org>> wrote:


Hi Stef,

Great! I'll send you a pull-request for the "hotfix" this evening. As 
I mentioned to Sven, I'll do some rework on the implementation and 
documentation when I find the time.


Günter

On 5/21/21 5:55 PM, ducasse wrote:

I checked and all the tests pass on Pharo80.
Now I did a little pass on the tests.
I do not have the time to migrate this lib to P9.
But I would accept Pull Requests :)

S.

On 21 May 2021, at 17:46, ducasse > wrote:


The old travis was telling that the code works in 6.1, 7 and 8.0
I added GithubActions for Pharo 80 and I will see.

S

On 21 May 2021, at 17:40, ducasse > wrote:


Hi gunter

I’m maintaining OSC
https://github.com/Ducasse/OSC
and TUIO
https://github.com/Ducasse/TUIO

Please do some PR if something does not work.

S

On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
mailto:pharo-dev@lists.pharo.org>> wrote:


Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since 
the Catalog Browser is marked as legacy, I was wondering how to 
submit the patch. Is there a git repository? I attached the 
fileout to this email in case anybody wants to take a look at the 
package or knows how/where to add it to Pharo 9.0,


Patch Note:

OSC relies on the removed /RWTextOrBinaryStream/ class which has 
very specific behavior that I could not emulate using the 
available stream and codec classes, so I pulled in the class from 
Squeak 5, renamed it to OSCStream and added it to the OSC 
package. This seemed to be the easiest way to do it without 
changing the OSC implementation, but I welcome any suggestions 
for a cleaner solution.


Günter

http://osc.st/>>










[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread ducasse
Thanks. 
I do not think that it is good to reintroduce this super ugly class. at the 
minimum it should be in a separate branch. 

S

> On 21 May 2021, at 18:06, Günter Khyo via Pharo-dev 
>  wrote:
> 
> Hi Stef,
> 
> Great! I'll send you a pull-request for the "hotfix" this evening. As I 
> mentioned to Sven, I'll do some rework on the implementation and 
> documentation when I find the time. 
> 
> Günter
> 
> On 5/21/21 5:55 PM, ducasse wrote:
>> I checked and all the tests pass on Pharo80. 
>> Now I did a little pass on the tests. 
>> I do not have the time to migrate this lib to P9.
>> But I would accept Pull Requests :)
>> 
>> S. 
>> 
>>> On 21 May 2021, at 17:46, ducasse >> > wrote:
>>> 
>>> The old travis was telling that the code works in 6.1, 7 and 8.0
>>> I added GithubActions for Pharo 80 and I will see.
>>> 
>>> S
>>> 
 On 21 May 2021, at 17:40, ducasse >>> > wrote:
 
 Hi gunter
 
 I’m maintaining OSC  
 https://github.com/Ducasse/OSC 
 and TUIO
 https://github.com/Ducasse/TUIO 
 
 Please do some PR if something does not work. 
 
 S
 
> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
> mailto:pharo-dev@lists.pharo.org>> wrote:
> 
> Hi,
> 
> I have ported the Open Sound Control package to Pharo 9.0. Since the 
> Catalog Browser is marked as legacy, I was wondering how to submit the 
> patch. Is there a git repository? I attached the fileout to this email in 
> case anybody wants to take a look at the package or knows how/where to 
> add it to Pharo 9.0, 
> 
> Patch Note:
> 
> OSC relies on the removed RWTextOrBinaryStream class which has very 
> specific behavior that I could not emulate using the available stream and 
> codec classes, so I pulled in the class from Squeak 5, renamed it to 
> OSCStream and added it to the OSC package. This seemed to be the easiest 
> way to do it without changing the OSC implementation, but I welcome any 
> suggestions for a cleaner solution.
> 
> Günter
> 
> http://osc.st/>>
 
>>> 
>> 



[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev

Hi Stef,

Great! I'll send you a pull-request for the "hotfix" this evening. As I 
mentioned to Sven, I'll do some rework on the implementation and 
documentation when I find the time.


Günter

On 5/21/21 5:55 PM, ducasse wrote:

I checked and all the tests pass on Pharo80.
Now I did a little pass on the tests.
I do not have the time to migrate this lib to P9.
But I would accept Pull Requests :)

S.

On 21 May 2021, at 17:46, ducasse > wrote:


The old travis was telling that the code works in 6.1, 7 and 8.0
I added GithubActions for Pharo 80 and I will see.

S

On 21 May 2021, at 17:40, ducasse > wrote:


Hi gunter

I’m maintaining OSC
https://github.com/Ducasse/OSC
and TUIO
https://github.com/Ducasse/TUIO

Please do some PR if something does not work.

S

On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
mailto:pharo-dev@lists.pharo.org>> wrote:


Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since 
the Catalog Browser is marked as legacy, I was wondering how to 
submit the patch. Is there a git repository? I attached the fileout 
to this email in case anybody wants to take a look at the package 
or knows how/where to add it to Pharo 9.0,


Patch Note:

OSC relies on the removed /RWTextOrBinaryStream/ class which has 
very specific behavior that I could not emulate using the available 
stream and codec classes, so I pulled in the class from Squeak 5, 
renamed it to OSCStream and added it to the OSC package. This 
seemed to be the easiest way to do it without changing the OSC 
implementation, but I welcome any suggestions for a cleaner solution.


Günter

http://osc.st/>>








[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev

Hi Sven,

Thanks for your response! That's a much nicer solution. Indeed, I did 
not want to change the implementation (for now) even though I don't 
really like the moded behavior RWTextOrBinaryStream and it was removed 
for good reason.


I would like to suggest to use the port with that ugly wart as it is for 
now, so that others can use OSC. When I get around to it, I will use 
your suggestions to retrofit the package and add some more documentation.


Günter

On 5/21/21 5:18 PM, Sven Van Caekenberghe wrote:

Hi Günter,

Thanks for answering, I expected that you would mention this aspect.

I don't know about OSC, but from your description it sounds like it basically 
is a binary protocol, where some sequences of bytes are to be interpreted as 
ASCII encoded strings.

I would just work on binary streams and do the encoding/decoding as needed.

ASCII is trivial, you can either do:

ZnCharacterEncoder ascii encodeString: 'OSC'

or

'OSC' asByteArray

And the inverse is either

ZnCharacterEncoder ascii decodeBytes: #[79 83 67].

or

#[79 83 67] asString.

The OSC spec says:

OSC-string
A sequence of non-null ASCII characters followed by a null, followed by 0-3 
additional null characters to make the total number of bits a multiple of 32.

One approach could be:

#writeOSCString: string on: stream

   stream nextPutAll: (ZnCharacterEncoder ascii encodeString: string).
   stream nextPut: 0.
   (string size + 1) // 4 timesRepeat: [ stream nextPut: 0 ]

#readOSCStringFrom: stream

   | string |
   string := ByteArray streamContents: [ :out |
 [ stream peekFor: 0 ] whileFalse: [ out nextPut: stream next ] ].
   (string size + 1) // 4 timesRepeat: [ stream next ].
   ^ ZnCharacterEncoder ascii decodeBytes: string

My point being that you probably don't need RWTextOrBinaryStream at all.

Of course, if you ported existing code and don't want to change it much, your 
solution is acceptable.

Sven


On 21 May 2021, at 15:39, Günter Khyo  wrote:

A RWTextOrBinaryStream instance can operate in binary or ascii mode, the mode 
can be switched at any time by sending ascii or binary, and some methods are 
mode-sensitive, e.g., contents will respond with a ByteArray in binary mode and 
a ByteString in ascii mode. (OSC uses ASCII encoding for addresses and strings, 
and binary formats for numbers and blobs.)

The OSC testcases and the parser rely on this behavior.

On 5/21/21 3:00 PM, Sven Van Caekenberghe wrote:

On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
  wrote:

Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
Browser is marked as legacy, I was wondering how to submit the patch. Is there 
a git repository? I attached the fileout to this email in case anybody wants to 
take a look at the package or knows how/where to add it to Pharo 9.0,

Patch Note:

OSC relies on the removed RWTextOrBinaryStream class which has very specific 
behavior that I could not emulate using the available stream and codec classes, 
so I pulled in the class from Squeak 5, renamed it to OSCStream and added it to 
the OSC package. This seemed to be the easiest way to do it without changing 
the OSC implementation, but I welcome any suggestions for a cleaner solution.


I am curious, what was the specific behaviour that you could not emulate ?



Günter





[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread ducasse
I checked and all the tests pass on Pharo80. 
Now I did a little pass on the tests. 
I do not have the time to migrate this lib to P9.
But I would accept Pull Requests :)

S. 

> On 21 May 2021, at 17:46, ducasse  wrote:
> 
> The old travis was telling that the code works in 6.1, 7 and 8.0
> I added GithubActions for Pharo 80 and I will see.
> 
> S
> 
>> On 21 May 2021, at 17:40, ducasse > > wrote:
>> 
>> Hi gunter
>> 
>> I’m maintaining OSC  
>>  https://github.com/Ducasse/OSC 
>> and TUIO
>>  https://github.com/Ducasse/TUIO 
>> 
>> Please do some PR if something does not work. 
>> 
>> S
>> 
>>> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>>> mailto:pharo-dev@lists.pharo.org>> wrote:
>>> 
>>> Hi,
>>> 
>>> I have ported the Open Sound Control package to Pharo 9.0. Since the 
>>> Catalog Browser is marked as legacy, I was wondering how to submit the 
>>> patch. Is there a git repository? I attached the fileout to this email in 
>>> case anybody wants to take a look at the package or knows how/where to add 
>>> it to Pharo 9.0, 
>>> 
>>> Patch Note:
>>> 
>>> OSC relies on the removed RWTextOrBinaryStream class which has very 
>>> specific behavior that I could not emulate using the available stream and 
>>> codec classes, so I pulled in the class   from Squeak 5, renamed it to 
>>> OSCStream and added it to the OSC package. This seemed to be the easiest 
>>> way to do it without changing the OSC implementation, but I welcome any 
>>> suggestions for a cleaner solution.
>>> 
>>> Günter
>>> 
>>> http://osc.st/>>
>> 
> 



[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread ducasse
The old travis was telling that the code works in 6.1, 7 and 8.0
I added GithubActions for Pharo 80 and I will see.

S

> On 21 May 2021, at 17:40, ducasse  wrote:
> 
> Hi gunter
> 
> I’m maintaining OSC  
>   https://github.com/Ducasse/OSC 
> and TUIO
>   https://github.com/Ducasse/TUIO 
> 
> Please do some PR if something does not work. 
> 
> S
> 
>> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>> mailto:pharo-dev@lists.pharo.org>> wrote:
>> 
>> Hi,
>> 
>> I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
>> Browser is marked as legacy, I was wondering how to submit the patch. Is 
>> there a git repository? I attached the fileout to this email in case anybody 
>> wants to take a look at the package or knows how/where to add it to Pharo 
>> 9.0, 
>> 
>> Patch Note:
>> 
>> OSC relies on the removed RWTextOrBinaryStream class which has very specific 
>> behavior that I could not emulate using the available stream and codec 
>> classes, so I pulled in the class from Squeak 5, renamed it to OSCStream and 
>> added it to the OSC package. This seemed to be the easiest way to do it 
>> without changing the OSC implementation, but I welcome any suggestions for a 
>> cleaner solution.
>> 
>> Günter
>> 
>> http://osc.st/>>
> 



[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread ducasse
Hi gunter

I’m maintaining OSC  
https://github.com/Ducasse/OSC
and TUIO
https://github.com/Ducasse/TUIO

Please do some PR if something does not work. 

S

> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>  wrote:
> 
> Hi,
> 
> I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
> Browser is marked as legacy, I was wondering how to submit the patch. Is 
> there a git repository? I attached the fileout to this email in case anybody 
> wants to take a look at the package or knows how/where to add it to Pharo 
> 9.0, 
> 
> Patch Note:
> 
> OSC relies on the removed RWTextOrBinaryStream class which has very specific 
> behavior that I could not emulate using the available stream and codec 
> classes, so I pulled in the class from Squeak 5, renamed it to OSCStream and 
> added it to the OSC package. This seemed to be the easiest way to do it 
> without changing the OSC implementation, but I welcome any suggestions for a 
> cleaner solution.
> 
> Günter
> 
> 



[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Sven Van Caekenberghe
Hi Günter,

Thanks for answering, I expected that you would mention this aspect.

I don't know about OSC, but from your description it sounds like it basically 
is a binary protocol, where some sequences of bytes are to be interpreted as 
ASCII encoded strings.

I would just work on binary streams and do the encoding/decoding as needed.

ASCII is trivial, you can either do:

ZnCharacterEncoder ascii encodeString: 'OSC'

or

'OSC' asByteArray

And the inverse is either

ZnCharacterEncoder ascii decodeBytes: #[79 83 67].

or

#[79 83 67] asString.

The OSC spec says:

OSC-string
A sequence of non-null ASCII characters followed by a null, followed by 0-3 
additional null characters to make the total number of bits a multiple of 32.

One approach could be:

#writeOSCString: string on: stream

  stream nextPutAll: (ZnCharacterEncoder ascii encodeString: string).
  stream nextPut: 0.
  (string size + 1) // 4 timesRepeat: [ stream nextPut: 0 ]

#readOSCStringFrom: stream

  | string |
  string := ByteArray streamContents: [ :out |
[ stream peekFor: 0 ] whileFalse: [ out nextPut: stream next ] ].
  (string size + 1) // 4 timesRepeat: [ stream next ].
  ^ ZnCharacterEncoder ascii decodeBytes: string

My point being that you probably don't need RWTextOrBinaryStream at all.

Of course, if you ported existing code and don't want to change it much, your 
solution is acceptable.

Sven

> On 21 May 2021, at 15:39, Günter Khyo  wrote:
> 
> A RWTextOrBinaryStream instance can operate in binary or ascii mode, the mode 
> can be switched at any time by sending ascii or binary, and some methods are 
> mode-sensitive, e.g., contents will respond with a ByteArray in binary mode 
> and a ByteString in ascii mode. (OSC uses ASCII encoding for addresses and 
> strings, and binary formats for numbers and blobs.)
> 
> The OSC testcases and the parser rely on this behavior. 
> 
> On 5/21/21 3:00 PM, Sven Van Caekenberghe wrote:
>> 
>>> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>>> 
>>>  wrote:
>>> 
>>> Hi,
>>> 
>>> I have ported the Open Sound Control package to Pharo 9.0. Since the 
>>> Catalog Browser is marked as legacy, I was wondering how to submit the 
>>> patch. Is there a git repository? I attached the fileout to this email in 
>>> case anybody wants to take a look at the package or knows how/where to add 
>>> it to Pharo 9.0, 
>>> 
>>> Patch Note:
>>> 
>>> OSC relies on the removed RWTextOrBinaryStream class which has very 
>>> specific behavior that I could not emulate using the available stream and 
>>> codec classes, so I pulled in the class from Squeak 5, renamed it to 
>>> OSCStream and added it to the OSC package. This seemed to be the easiest 
>>> way to do it without changing the OSC implementation, but I welcome any 
>>> suggestions for a cleaner solution.
>>> 
>> I am curious, what was the specific behaviour that you could not emulate ?
>> 
>> 
>>> Günter
>>> 
>>> 
>>> 


[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev
A RWTextOrBinaryStream instance can operate in binary or ascii mode, the 
mode can be switched at any time by sending /ascii/ or /binary/, and 
some methods are mode-sensitive, e.g., /contents/ will respond with a 
ByteArray in binary mode and a ByteString in ascii mode. (OSC uses ASCII 
encoding for addresses and strings, and binary formats for numbers and 
blobs.)


The OSC testcases and the parser rely on this behavior.

On 5/21/21 3:00 PM, Sven Van Caekenberghe wrote:



On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev  
wrote:

Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
Browser is marked as legacy, I was wondering how to submit the patch. Is there 
a git repository? I attached the fileout to this email in case anybody wants to 
take a look at the package or knows how/where to add it to Pharo 9.0,

Patch Note:

OSC relies on the removed RWTextOrBinaryStream class which has very specific 
behavior that I could not emulate using the available stream and codec classes, 
so I pulled in the class from Squeak 5, renamed it to OSCStream and added it to 
the OSC package. This seemed to be the easiest way to do it without changing 
the OSC implementation, but I welcome any suggestions for a cleaner solution.

I am curious, what was the specific behaviour that you could not emulate ?


Günter




[Pharo-dev] Re: Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Sven Van Caekenberghe



> On 21 May 2021, at 14:02, Günter Khyo via Pharo-dev 
>  wrote:
> 
> Hi,
> 
> I have ported the Open Sound Control package to Pharo 9.0. Since the Catalog 
> Browser is marked as legacy, I was wondering how to submit the patch. Is 
> there a git repository? I attached the fileout to this email in case anybody 
> wants to take a look at the package or knows how/where to add it to Pharo 
> 9.0, 
> 
> Patch Note:
> 
> OSC relies on the removed RWTextOrBinaryStream class which has very specific 
> behavior that I could not emulate using the available stream and codec 
> classes, so I pulled in the class from Squeak 5, renamed it to OSCStream and 
> added it to the OSC package. This seemed to be the easiest way to do it 
> without changing the OSC implementation, but I welcome any suggestions for a 
> cleaner solution.

I am curious, what was the specific behaviour that you could not emulate ?

> Günter
> 
> 


[Pharo-dev] Open Sound Control Package for Pharo 9.0

2021-05-21 Thread Günter Khyo via Pharo-dev

Hi,

I have ported the Open Sound Control package to Pharo 9.0. Since the 
Catalog Browser is marked as legacy, I was wondering how to submit the 
patch. Is there a git repository? I attached the fileout to this email 
in case anybody wants to take a look at the package or knows how/where 
to add it to Pharo 9.0,


Patch Note:

OSC relies on the removed /RWTextOrBinaryStream/ class which has very 
specific behavior that I could not emulate using the available stream 
and codec classes, so I pulled in the class from Squeak 5, renamed it to 
OSCStream and added it to the OSC package. This seemed to be the easiest 
way to do it without changing the OSC implementation, but I welcome any 
suggestions for a cleaner solution.


Günter

Object subclass: #OSCPacket
instanceVariableNames: 'byteStream'
classVariableNames: ''
package: 'OSC-Kernel'!

!OSCPacket methodsFor: 'action' stamp: 'mga 9/17/2006 19:17'!
sendToYourself
self sendTo: NetNameResolver localHostAddress port: 57123! !

!OSCPacket methodsFor: 'action'!
sendTo: aByteArray port: aPort 
"Take care, A byte array is not a string.
If you want to send to e.g. '192.168.0.2' 
sendToAddressString: port: instead
But use this one if you want to be fast."
| aSocket |
Socket initializeNetwork.
aSocket := Socket newUDP.
aSocket
sendUDPData: self byteArray
toHost: aByteArray
port: aPort;
 close;
 destroy! !

!OSCPacket methodsFor: 'action' stamp: 'mga 9/17/2006 19:17'!
sendToAddressString: anAddressString port: aPort 
self 
sendTo: ((anAddressString findTokens: '.') collect: [:e | e 
asNumber]) 
asByteArray
port: aPort! !


!OSCPacket methodsFor: 'initialization' stamp: 'gk 5/18/2021 18:51'!
initializeFor: somePackets
byteStream := 
(OSCStream on: '')
yourself.
self print: somePackets onOSCStream: byteStream! !


!OSCPacket methodsFor: 'accessing' stamp: 'mga 3/28/2005 09:24'!
byteArray
^self byteStream binary contents! !

!OSCPacket methodsFor: 'accessing' stamp: 'mga 3/28/2005 07:56'!
oSCSize
^self byteArray size! !

!OSCPacket methodsFor: 'accessing' stamp: 'mga 3/16/2005 08:58'!
byteStream
^byteStream! !


!OSCPacket methodsFor: 'printing' stamp: 'mga 6/24/2000 14:09'!
print: somePackets onOSCStream: aStream
self subclassResponsibility! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

OSCPacket class
instanceVariableNames: ''!

!OSCPacket class methodsFor: 'access to cache' stamp: 'StephaneDucasse 
9/29/2012 22:59'!
for: somePackets
^ self new initializeFor: somePackets ! !


OSCPacket subclass: #OSCBundle
instanceVariableNames: 'packets'
classVariableNames: ''
package: 'OSC-Kernel'!

!OSCBundle methodsFor: 'printing' stamp: 'StephaneDucasse 9/29/2012 23:02'!
printTimeTagOnOSCStream: aStream
"Not yet implemented, just print 8 empty bytes"
8 timesRepeat: [ aStream nextPut: 0 ]! !

!OSCBundle methodsFor: 'printing' stamp: 'StephaneDucasse 9/29/2012 23:02'!
print: somePackets onOSCStream: aStream

'#bundle' printOnOSCStream: aStream.
self printTimeTagOnOSCStream: aStream.
somePackets do: [ :aPacket |
aPacket oSCSize printOnOSCStream: aStream.
aStream nextPutAll: aPacket byteArray ]
! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

OSCBundle class
instanceVariableNames: ''!

!OSCBundle class methodsFor: 'examples' stamp: 'mga 6/24/2000 14:07'!
example1
^self for: {OSCMessage example1 .  OSCMessage example2}
! !

!OSCBundle class methodsFor: 'examples' stamp: 'mga 6/24/2000 14:08'!
example2
^self for: {OSCBundle example1 . OSCMessage example3}! !


OSCPacket subclass: #OSCMessage
instanceVariableNames: ''
classVariableNames: ''
package: 'OSC-Kernel'!

!OSCMessage methodsFor: 'printing' stamp: 'StephaneDucasse 9/29/2012 23:03'!
printValues: someValues onOSCStream: aStream
someValues do: [ :each | each printOnOSCStream: aStream ]
! !

!OSCMessage methodsFor: 'printing' stamp: 'mga 3/29/2005 21:37'!
print: someArguments onOSCStream: aStream

| someParams |
self printAddress: someArguments first onOSCStream: aStream.
"Put the comma, also parameterless messages have one"
aStream nextPut: 44.
someParams := someArguments copyFrom: 2 to: someArguments size.
self
printTypesOf: someParams on: aStream;
printValues: someParams onOSCStream: aStream
! !

!OSCMessage methodsFor: 'printing' stamp: 'StephaneDucasse 9/29/2012 23:02'!
printAddress: anAddress onOSCStream: aStream

anAddress printOnOSCStream: aStream

! !

!OSCMessage methodsFor: 

[Pharo-dev] This week (20/2021) on the Pharo Issue Tracker

2021-05-21 Thread Marcus Denker
We merged 17 Pull Requests and closed 13 issues.

As we are preparing the release of Pharo9, we are focussing in bug fixes and 
trivial cleanups.


Update to fuel 303 #9283


https://github.com/pharo-project/pharo/pull/9283

Fixes
=

improving-drtests-plugin-support #9276
https://github.com/pharo-project/pharo/pull/9276

Resurrected old beahviour where it was possible to use cmd-s
https://github.com/pharo-project/pharo/pull/9293

Add possibility to wrap text in the text comparator #9200
https://github.com/pharo-project/pharo/pull/9200

fixing light/dark themes disabled colors #9281
https://github.com/pharo-project/pharo/pull/9281

fix SHRBTextStyler messing Transcript. #9292
https://github.com/pharo-project/pharo/pull/9292

slowFactorial call corrected #9295
https://github.com/pharo-project/pharo/pull/9295

9093--in-floatArray-changes-the-second-array- #9149
https://github.com/pharo-project/pharo/pull/9149

8897 restart quick method smashes stack #9185
https://github.com/pharo-project/pharo/pull/9185

RB - Improve Refactoring presenters #9285
https://github.com/pharo-project/pharo/pull/9285

RB - Fix Lazy initialization #9265
https://github.com/pharo-project/pharo/pull/9265


Cleanups



Remove argument from parseExpression: and parseMethod: in Parser #9279
https://github.com/pharo-project/pharo/pull/9279

Deprecations for removed #parse methods in RBParser #9300
https://github.com/pharo-project/pharo/pull/9300

Mark abstract classes in Microdown package - Second attempt #9212
https://github.com/pharo-project/pharo/pull/9212

9280-CompiledMethod--valueWithReceiver-aReceiver-arguments-anArray-comments-is-arcane
 #9296
https://github.com/pharo-project/pharo/pull/9296

roundUpTo deserves executable comments #9298
https://github.com/pharo-project/pharo/pull/9298

Removes method DialogWindow >> setButtonFont: #9274
https://github.com/pharo-project/pharo/pull/9274