[Vm-dev] VM Maker: VMMaker.oscog-eem.2809.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Sep 19 01:16:30 UTC 2020


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.2809.mcz

==================== Summary ====================

Name: VMMaker.oscog-eem.2809
Author: eem
Time: 18 September 2020, 6:16:21.81309 pm
UUID: aec35081-c722-4000-9fbb-1794dd09041c
Ancestors: VMMaker.oscog-eem.2808

Clarify some of the SoundPlgin primitives and generalize them for 16-bit and 32-bit containers.

=============== Diff against VMMaker.oscog-eem.2808 ===============

Item was added:
+ ----- Method: SoundPlugin>>frameCountOf: (in category 'support') -----
+ frameCountOf: buf
+ 	"Answer the number of 16-bit sound sample pairs in buf, a pointer to the first indexable field of a sound buffer."
+ 	<inline: #always>
+ 	^(interpreterProxy byteSizeOf: buf cPtrAsOop) / ((self sizeof: #short) * 2)!

Item was changed:
  ----- Method: SoundPlugin>>primitiveSoundInsertSamples:from:leadTime: (in category 'primitives') -----
  primitiveSoundInsertSamples: frameCount from: buf leadTime: leadTime 
  	"Insert a buffer's worth of sound samples into the currently playing  
  	buffer. Used to make a sound start playing as quickly as possible. The  
  	new sound is mixed with the previously buffered sampled."
  	"Details: Unlike primitiveSoundPlaySamples, this primitive always starts  
  	with the first sample the given sample buffer. Its third argument  
  	specifies the number of samples past the estimated sound output buffer  
  	position the inserted sound should start. If successful, it returns the  
  	number of samples inserted."
+ 	
+ 	"N.B. At least on Windows and MacOS Cocoa circa late 2020 this is unsupported.
+ 	 snd_InsertSamplesFromLeadTime merely answers zero."
  	| framesPlayed |
  	self primitive: 'primitiveSoundInsertSamples'
  		parameters: #(SmallInteger WordsOrShorts SmallInteger).
+ 	(self cCoerce: frameCount to: #usqInt) > (self frameCountOf: buf) ifTrue:
- 	(self cCoerce: frameCount to: #usqInt) > (interpreterProxy slotSizeOf: buf cPtrAsOop) ifTrue:
  		[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  
  	framesPlayed := self snd_InsertSamplesFromLeadTime: frameCount _: buf _: leadTime.
  	framesPlayed >= 0
  		ifTrue: [interpreterProxy methodReturnInteger: framesPlayed]
  		ifFalse: [interpreterProxy primitiveFail]!

Item was changed:
  ----- Method: SoundPlugin>>primitiveSoundPlaySamples:from:startingAt: (in category 'primitives') -----
  primitiveSoundPlaySamples: frameCount from: buf startingAt: startIndex 
+ 	"Output a buffer's worth of stereo sound samples.  The frameCount is the number of 16-bit sample pairs.
+ 	 See e.g. platforms/iOS/plugins/SoundPlugin/sqSqueakSoundCoreAudio.m:
+ 		#define SqueakFrameSize	4	// guaranteed (see class SoundPlayer)
+ 	 Of course there is no FrameSize in Squeak 5.x/6.x; sigh..."
- 	"Output a buffer's worth of stereo sound samples."
  	| framesPlayed |
  	self primitive: 'primitiveSoundPlaySamples'
  		parameters: #(SmallInteger WordsOrShorts SmallInteger).
+ 	(startIndex >= 1
+ 	 and: [startIndex + frameCount - 1 <= (self frameCountOf: buf)]) ifFalse:
- 	(startIndex >= 1 and: [startIndex + frameCount - 1 <= (interpreterProxy slotSizeOf: buf cPtrAsOop)]) ifFalse:
  		[^interpreterProxy primitiveFailFor: PrimErrBadArgument].
  
  	framesPlayed := self snd_PlaySamplesFromAtLength: frameCount _: buf _: startIndex - 1.
  	framesPlayed >= 0
  		ifTrue: [interpreterProxy methodReturnInteger: framesPlayed]
  		ifFalse: [interpreterProxy primitiveFail]!

Item was changed:
  ----- Method: SoundPlugin>>primitiveSoundRecordSamplesInto:startingAt: (in category 'primitives') -----
  primitiveSoundRecordSamplesInto: buf startingAt: startWordIndex 
+ 	"Record a buffer's worth of (mono?) 16-bit sound samples."
+ 	| bufSizeInBytes samplesRecorded byteOffset |
- 	"Record a buffer's worth of 16-bit sound samples."
- 	| bufSizeInBytes samplesRecorded bufPtr byteOffset |
  	<var: #bufPtr type: #'char*'>
  	self primitive: 'primitiveSoundRecordSamples'
  		parameters: #(WordsOrShorts SmallInteger).
  
+ 	bufSizeInBytes := interpreterProxy byteSizeOf: buf cPtrAsOop.
- 	bufSizeInBytes := (interpreterProxy slotSizeOf: buf cPtrAsOop) * 4.
  	byteOffset := (startWordIndex - 1) * 2.
  
  	(startWordIndex >= 1 and: [byteOffset < bufSizeInBytes]) ifFalse:
  		[^interpreterProxy primitiveFailFor: PrimErrBadIndex].
  
+ 	samplesRecorded := self snd_RecordSamplesIntoAtLength: (self cCoerce: buf to: #'char *') + byteOffset
+ 							_: 0
+ 							_: bufSizeInBytes - byteOffset.
- 	bufPtr := (self cCoerce: buf to: #'char *') + byteOffset.
- 	samplesRecorded := self snd_RecordSamplesIntoAtLength: bufPtr _: 0 _: bufSizeInBytes - byteOffset.
  	interpreterProxy failed ifFalse:
  		[^samplesRecorded asPositiveIntegerObj]!

Item was added:
+ ----- Method: SoundPlugin>>sampleSizeOf: (in category 'support') -----
+ sampleSizeOf: buf
+ 	"Answer the number of 16-bit sound samples in buf, a pointer to the first indexable field of a sound buffer."
+ 	<inline: #always>
+ 	^(interpreterProxy byteSizeOf: buf cPtrAsOop) / (self sizeof: #short)!



More information about the Vm-dev mailing list