[squeak-dev] The Trunk: Sound-nice.28.mcz

Levente Uzonyi leves at elte.hu
Mon Apr 11 15:14:21 UTC 2011


On Mon, 11 Apr 2011, commits at source.squeak.org wrote:

> Nicolas Cellier uploaded a new version of Sound to project The Trunk:
> http://source.squeak.org/trunk/Sound-nice.28.mcz
>
> ==================== Summary ====================
>
> Name: Sound-nice.28
> Author: nice
> Time: 11 April 2011, 4:49:01.623 pm
> UUID: 3de2013e-36c1-bd46-a5db-a56a85de109a
> Ancestors: Sound-nice.27
>
> Use #repeat instead of [true] whileTrue

Can VMMaker compile #repeat to C? According to 
http://wiki.squeak.org/squeak/2267 it can't, but the wiki page may not be 
up to date.


Levente

>
> =============== Diff against Sound-nice.27 ===============
>
> Item was changed:
>  ----- Method: ADPCMCodec>>nextBits: (in category 'bit streaming') -----
>  nextBits: n
>  	"Answer the next n bits of my bit stream as an unsigned integer."
>
>  	| result remaining shift |
>  	<inline: true>
>
>  	result := 0.
>  	remaining := n.
> +
> + 	[
> - 	[true] whileTrue: [
>  		shift := remaining - bitPosition.
>  		result := result + (currentByte bitShift: shift).
>  		shift > 0
>  			ifTrue: [  "consumed currentByte buffer; fetch next byte"
>  				remaining := remaining - bitPosition.
>  				currentByte := (encodedBytes at: (byteIndex := byteIndex + 1)).
>  				bitPosition := 8]
>  			ifFalse: [  "still some bits left in currentByte buffer"
>  				bitPosition := bitPosition - remaining.
>  				"mask out the consumed bits:"
>  				currentByte := currentByte bitAnd: (255 bitShift: (bitPosition - 8)).
> + 				^ result]] repeat
> - 				^ result]].
>  !
>
> Item was changed:
>  ----- Method: ADPCMCodec>>nextBits:put: (in category 'bit streaming') -----
>  nextBits: n put: anInteger
>  	"Write the next n bits to my bit stream."
>
>  	| buf bufBits bitsAvailable shift |
>  	<inline: true>
>
>  	buf := anInteger.
>  	bufBits := n.
> + 	[
> - 	[true] whileTrue: [
>  		bitsAvailable := 8 - bitPosition.
>  		shift := bitsAvailable - bufBits.  "either left or right shift"
>  		"append high bits of buf to end of currentByte:"
>  		currentByte := currentByte + (buf bitShift: shift).
>  		shift < 0
>  			ifTrue: [  "currentByte buffer filled; output it"
>  				encodedBytes at: (byteIndex := byteIndex + 1) put: currentByte.
>  				bitPosition := 0.
>  				currentByte := 0.
>  				"clear saved high bits of buf:"
>  				buf := buf bitAnd: (1 bitShift: 0 - shift) - 1.
>  				bufBits := bufBits - bitsAvailable]
>  			ifFalse: [  "still some bits available in currentByte buffer"
>  				bitPosition := bitPosition + bufBits.
> + 				^ self]] repeat
> - 				^ self]].
>  !
>
> Item was changed:
>  ----- Method: MIDISynth>>midiTrackingLoop (in category 'as yet unclassified') -----
>  midiTrackingLoop
>
>  	midiParser clearBuffers.
> +
> + 	[self processMIDI ifFalse: [(Delay forMilliseconds: 5) wait]] repeat!
> - 	[true] whileTrue: [
> - 		self processMIDI ifFalse: [(Delay forMilliseconds: 5) wait]].
> - !
>
>
>



More information about the Squeak-dev mailing list