[Etoys] [ENH]SoundLibraryCompress

karl karl.ramberg at comhem.se
Wed Dec 5 16:12:20 EST 2007


"Change Set:        SoundLibraryCompress
Date:            5 December 2007
Author:            Karl Ramberg

Add a halo menu item that GSM compress and replace the selected sound
Now also OggVorbis and OggSpeex codec"
-------------- next part --------------
'From etoys2.3 of 2 December 2007 [latest update: #1820] on 5 December 2007 at 10:07:09 pm'!
"Change Set:		SoundLibraryCompress
Date:			5 December 2007
Author:			Karl Ramberg

Add a halo menu item that GSM compress and replace the selected sound 
Now also OggVorbis and OggSpeex codec"!


!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/5/2007 22:03'!
addCustomMenuItems: aMenu hand: aHand
	"Add custom menu items to a menu"

	super addCustomMenuItems: aMenu hand: aHand.
	aMenu addTranslatedList: #(
		('wave editor' edit 'open a tool which, operating with the selected sound as a point of departure, will allow you to construct a new "instrument"')
		('GSM compress sound' compressWithGSM 'compress the sound with GSM compression and replace the uncompressed one')
		('OggSpeex compress sound' compressWithOggSpeex 'compress the sound with OggSpeex compression and replace the uncompressed one')
		('OggVorbis compress sound' compressWithOggVorbis 'compress the sound with OggVorbis compression and replace the uncompressed one')
	) translatedNoop! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/5/2007 16:16'!
compressWithGSM
	"Compress the sound."
| newSound name writer |
soundIndex > 0
		ifTrue: [newSound _ GSMCodec new compressSound:currentSound .].
		writer := ByteArray new writeStream.
	 newSound channels
				do: [:channel | writer nextPutAll: channel].
	name := listBox getList at: soundIndex. 
	SampledSound removeSoundNamed: name.
	SampledSound addLibrarySoundNamed: name bytes: writer contents codecSignature: newSound codecSignature
	
! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/5/2007 22:04'!
compressWithOggSpeex
	"Compress the sound."
	| newSound name |
	soundIndex > 0
		ifTrue: [newSound := OggVorbisCodec new encodeSoundBuffer: currentSound samples].
	name := listBox getList at: soundIndex.
	SampledSound removeSoundNamed: name.
	SampledSound
		addLibrarySoundNamed: name
		bytes: newSound
		codecSignature: OggVorbisCodec className! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/5/2007 16:20'!
compressWithOggVorbis
	"Compress the sound."
| newSound name writer |
soundIndex > 0
		ifTrue: [newSound _ GSMCodec new compressSound:currentSound .].
		writer := ByteArray new writeStream.
	 newSound channels
				do: [:channel | writer nextPutAll: channel].
	name := listBox getList at: soundIndex. 
	SampledSound removeSoundNamed: name.
	SampledSound addLibrarySoundNamed: name bytes: writer contents codecSignature: newSound codecSignature
	
! !



More information about the etoys-dev mailing list