Sound compression Re: [squeak-dev] Re: to be deployed Epaati version is out!

karl karl.ramberg at comhem.se
Wed Apr 23 11:01:20 UTC 2008


Hi
I looked at the project and noticed you did not use sound compression.
I think you could save a lot of space using Ogg Vorbis or Speex.
To compress the sounds you do this:
    1 File in attached change set
    2 Open SoundLibraryTool found in Multimedia in ObjectTool
    3 Select the sound to compress
    4 Bring up halo on the SoundLibraryTool
    5 In the halo menu there is a option to compress the sound
    6 goto3

Karl
-------------- next part --------------
'From etoys2.3 of 2 December 2007 [latest update: #1849] on 5 January 2008 at 2:19:47 am'!
"Change Set:		SoundLibraryCompress
Date:			5 January 2008
Author:			Karl Ramberg

Add a halo menu item that GSM compress and replace the selected sound 
Now also OggVorbis and OggSpeex codec. Prevents the default library sounds to be compressed. Stops playing the current sound if its deleted"!


!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 1/5/2008 02:18'!
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 'Simple compression')
		('OggSpeex compress sound' compressWithOggSpeex 'Speech compression')
		('OggVorbis compress sound' compressWithOggVorbis 'Music compression')
	) translatedNoop
! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/6/2007 09:03'!
compressWithGSM
	"Compress the sound."
	self compressWith: GSMCodec! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/6/2007 09:03'!
compressWithOggSpeex
	"Compress the sound."
	self compressWith: OggSpeexCodec! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/14/2007 23:19'!
compressWithOggVorbis
	"Compress the sound."
        self compressWith: OggVorbisCodec.
    
	! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 1/5/2008 02:17'!
compressWith: aCodec 
	"Compress the sound."
	| newSound name writer |
	soundIndex = 0
		ifTrue: [^ self inform: 'No sound selected' translated].
	name := listBox getList at: soundIndex.
	(SampledSound universalSoundKeys includes: name)
		ifTrue: [^ self inform: 'You can not compress this sound' translated].
	newSound := currentSound compressWith: aCodec.
	writer := ByteArray new writeStream.
	newSound channels
		do: [:channel | writer nextPutAll: channel].
	SampledSound removeSoundNamed: name.
	SampledSound
		addLibrarySoundNamed: name
		bytes: writer contents
		codecSignature: newSound codecSignature.
	currentSound := SampledSound soundNamed: name! !

!SoundLibraryTool methodsFor: 'menu' stamp: 'kfr 12/15/2007 00:00'!
deleteSound
	"Delete the selected sound, if appropriate."

	 | name |
	soundIndex = 0
		ifTrue: [^ self inform: 'No sound selected' translated].
	currentSound pause.
	name := listBox getList at: soundIndex.
	(SampledSound universalSoundKeys includes: name)
		ifTrue: [self inform: 'You can not delete this sound' translated]
		ifFalse: [ScriptingSystem removeFromSoundLibrary: name].
	self soundIndex: 0.
	listBox updateList! !



More information about the Squeak-dev mailing list