Skip to content

Commit

Permalink
Copy some methods from PositionableStream to FSWriteStream
Browse files Browse the repository at this point in the history
This is done to allow AbstractSound/SampledSound to use these methods when reading/writing WAV and AIFF while using an FSWriteStream.
  • Loading branch information
MariusDoe committed Oct 17, 2023
1 parent 00b08c2 commit 4b35071
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 3 deletions.
14 changes: 14 additions & 0 deletions src/Squot.package/FSWriteStream.extension/instance/int16..st
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*Squot-Mapper-FSStream-compatibility
int16: anInteger
"copied from PositionableStream"
"Store the given signed, 16-bit integer on this (binary) stream."

| n |
(anInteger < -16r8000) | (anInteger >= 16r8000)
ifTrue: [self error: 'outside 16-bit integer range'].

anInteger < 0
ifTrue: [n := 16r10000 + anInteger]
ifFalse: [n := anInteger].
self nextPut: (n digitAt: 2).
self nextPut: (n digitAt: 1).
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*Squot-Mapper-FSStream-compatibility
nextLittleEndianNumber: n put: value
"copied from PositionableStream"
"Answer the next n bytes as a positive Integer or LargePositiveInteger, where the bytes are ordered from least significant to most significant."
| bytes |
bytes := ByteArray new: n.
1 to: n do: [: i | bytes at: i put: (value digitAt: i)].
self nextPutAll: bytes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"class" : {
},
"instance" : {
"int16:" : "mad 10/17/2023 12:45",
"nextLittleEndianNumber:put:" : "mad 10/17/2023 12:45" } }
2 changes: 2 additions & 0 deletions src/Squot.package/FSWriteStream.extension/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{
"name" : "FSWriteStream" }
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ version-io
readVersionFrom: aStream
^ SampledSound
perform: ('from{1}Stream:' format: {self encoding}) asSymbol
with: aStream

with: aStream
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"wavEncoding" : "mad 9/20/2023 17:58" },
"instance" : {
"isValidVersion:" : "mad 9/20/2023 14:49",
"readVersionFrom:" : "mad 9/20/2023 17:56",
"readVersionFrom:" : "mad 10/17/2023 12:22",
"transformVersion:ifFail:" : "mad 10/17/2023 12:33",
"versionAsMorph:" : "mad 9/21/2023 12:37",
"versionTypeName" : "mad 9/20/2023 15:02",
Expand Down

0 comments on commit 4b35071

Please sign in to comment.