Hey, there!
This does not work (i.e. primitive failed):
m := Morph new.
c := Color white.
m perform: #color: withArguments: (WeakArray with: c).
Is this primitive-fail okay? If yes, we have a bug in WeakMessageSend >>
#collectArguments: because it will always return a WeakArray if the arg
sizes does not match. Usually a normal array otherwise.
I observed this kind of bug when using our object events like this:
m1 := Morph new.
m2 := Morph new.
m1 when: #baz send: #color: to: m2 with: Color black.
m1 triggerEvent: #baz withArguments: {Color white. #blubb}. "fails due to
weak array"
m1 triggerEvent: #baz withArguments: {Color white}. "works due to normal
array"
Best,
Marcel
--
View this message in context: http://forum.world.st/perform-withArguments-not-working-with-WeakArray-tp48…
Sent from the Squeak - Dev mailing list archive at Nabble.com.
Marcel Taeumel uploaded a new version of Sound to project The Trunk:
http://source.squeak.org/trunk/Sound-mt.56.mcz
==================== Summary ====================
Name: Sound-mt.56
Author: mt
Time: 28 April 2016, 2:34:02.190031 pm
UUID: 24fb4170-db03-d446-88d6-bc68d542761c
Ancestors: Sound-mt.55
Due to excessive use of the shut-down-mechanism in sound code, fix all the places where #shutDown was called but nowadays #shutDown: is implemented.
Now, you can safely to this again:
SoundPlayer stopReverb. "revert with #startReverb"
TrashCanMorph playDeleteSound.
=============== Diff against Sound-mt.55 ===============
Item was changed:
----- Method: AbstractSound class>>testFMInteractively (in category 'examples') -----
testFMInteractively
"Experiment with different settings of the FM modulation and multiplier settings interactively by moving the mouse. The top-left corner of the screen is 0 for both parameters. Stop when the mouse is pressed."
"AbstractSound testFMInteractively"
| s mousePt lastVal status mod ratio |
SoundPlayer startPlayerProcessBufferSize: 1100 rate: 11025 stereo: false.
s := FMSound pitch: 440.0 dur: 200.0 loudness: 0.2.
SoundPlayer playSound: s.
lastVal := nil.
[Sensor anyButtonPressed] whileFalse: [
mousePt := Sensor cursorPoint.
mousePt ~= lastVal ifTrue: [
mod := mousePt x asFloat / 20.0.
ratio := mousePt y asFloat / 20.0.
s modulation: mod ratio: ratio.
lastVal := mousePt.
status :=
'mod: ', mod printString, '
ratio: ', ratio printString.
status displayOn: Display at: 10@10]].
+ SoundPlayer shutDown: true.
- SoundPlayer shutDown.
!
Item was changed:
----- Method: MIDISynth class>>example (in category 'examples') -----
example
"Here's one way to run the MIDI synth. It will get a nice Morphic UI later. Click the mouse to stop running it. (Mac users note: be sure you have MIDI interface adaptor plugged in, or Squeak will hang waiting for the external clock signal.)."
"MIDISynth example"
| portNum synth |
portNum := SimpleMIDIPort inputPortNumFromUser.
portNum ifNil: [^ self].
SoundPlayer useShortBuffer.
synth := MIDISynth new
midiPort: (SimpleMIDIPort openOnPortNumber: portNum).
synth midiParser ignoreCommand: 224. "filter out pitch bends"
1 to: 16 do: [:i |
(synth channel: i) instrument:
(AbstractSound soundNamed: 'oboe1')].
1 to: 16 do: [:ch | synth volumeForChannel: ch put: 0.2].
synth processMIDIUntilMouseDown.
+ SoundPlayer shutDown: true; initialize. "revert to normal buffer size"
- SoundPlayer shutDown; initialize. "revert to normal buffer size"
!
Item was changed:
----- Method: MIDISynth>>stopMIDITracking (in category 'as yet unclassified') -----
stopMIDITracking
process ifNotNil: [
process terminate.
process := nil].
+ SoundPlayer shutDown: true; initialize. "revert to normal buffer size"
- SoundPlayer shutDown; initialize. "revert to normal buffer size"
!
Item was changed:
----- Method: SoundPlayer class>>boinkScale (in category 'primitive test') -----
boinkScale
"Tests the sound output primitives by playing a scale."
"SoundPlayer boinkScale"
| sineTable pan |
+ self shutDown: true.
- self shutDown.
SamplingRate := 11025.
Stereo := true.
sineTable := self sineTable: 1000.
Buffer := SoundBuffer newStereoSampleCount: 1000.
BufferIndex := 1.
self primSoundStartBufferSize: Buffer stereoSampleCount
rate: SamplingRate
stereo: Stereo.
pan := 0.
#(261.626 293.665 329.628 349.229 391.996 440.001 493.884 523.252) do: [:p |
self boinkPitch: p dur: 0.3 loudness: 300 waveTable: sineTable pan: pan.
pan := pan + 125].
self boinkPitch: 261.626 dur: 1.0 loudness: 300 waveTable: sineTable pan: 500.
self primSoundStop.
+ self shutDown: true.
- self shutDown.
SoundPlayer initialize. "reset sampling rate, buffer size, and stereo flag"
!
Item was changed:
----- Method: SoundPlayer class>>playLoop (in category 'player process') -----
playLoop
"The sound player process loop."
| bytesPerSlice count willStop mayStop |
mayStop := self stopSoundWhenDone.
bytesPerSlice := Stereo ifTrue: [4] ifFalse: [2].
[
[(count := self primSoundAvailableBytes // bytesPerSlice) > 100]
whileFalse: [ReadyForBuffer wait].
count := count min: Buffer stereoSampleCount.
PlayerSemaphore critical: [
ActiveSounds := ActiveSounds select: [:snd | snd samplesRemaining > 0].
ActiveSounds do: [:snd |
snd ~~ SoundJustStarted ifTrue: [
snd playSampleCount: count into: Buffer startingAt: 1]].
ReverbState == nil ifFalse: [
ReverbState applyReverbTo: Buffer startingAt: 1 count: count].
self primSoundPlaySamples: count from: Buffer startingAt: 1.
willStop := mayStop and:[
(ActiveSounds size = 0) and:[
self isAllSilence: Buffer size: count]].
LastBuffer ifNotNil:[
LastBuffer replaceFrom: 1 to: LastBuffer size with: Buffer startingAt: 1.
].
willStop
+ ifTrue:[self shutDown: true. PlayerProcess := nil]
- ifTrue:[self shutDown. PlayerProcess := nil]
ifFalse:[Buffer primFill: 0].
SoundJustStarted := nil].
willStop ifTrue:[^self] ] repeat
!
Item was changed:
----- Method: SoundPlayer class>>useShortBuffer (in category 'initialization') -----
useShortBuffer
"Experimental support for real-time MIDI input. This only works on platforms whose hardware allows very short buffer sizes. It has been tested on a Macintosh Powerbook G3."
"SoundPlayer useShortBuffer"
+ self shutDown: true.
- self shutDown.
BufferMSecs := 15.
SoundPlayer
startPlayerProcessBufferSize: (BufferMSecs * SamplingRate) // 1000
rate: SamplingRate
stereo: Stereo.
!
Item was changed:
----- Method: SoundRecorder>>startRecording (in category 'recording controls') -----
startRecording
"Turn on the sound input driver and start the recording process. Initially, recording is paused.
If the primStartRecordingDesiredSampleRate:... fails it almost certainly means we have no usable
sound input device. Rather than having the prim raise a failure error we let it quietly do nothing
(since I hate trying to debug errors inside a critical block) and check the actual sampling rate later.
If the sampling rate is 0 we know the startup failed and raise an application level Signal to let any
user code know about the problem.
You might think we should also use the stopRecording message to close things down cleanly but
that simply results in astorm of attempts to start recording so it is simpler to let it be deluded. An
attempts to start recording will repeat the test and thereby handle any plug-in hardware etc."
recordLevel ifNil: [recordLevel := 0.5]. "lazy initialization"
+ CanRecordWhilePlaying ifFalse: [SoundPlayer shutDown: true].
- CanRecordWhilePlaying ifFalse: [SoundPlayer shutDown].
recordProcess ifNotNil: [self stopRecording].
paused := true.
meteringBuffer := SoundBuffer newMonoSampleCount: 1024.
meterLevel := 0.
self allocateBuffer.
Smalltalk newExternalSemaphoreDo: [ :semaphore :index |
bufferAvailableSema := semaphore.
self primStartRecordingDesiredSampleRate: samplingRate asInteger
stereo: stereo
semaIndex: index ].
RecorderActive := true.
samplingRate := self primGetActualRecordingSampleRate.
samplingRate = 0 ifTrue: [ Warning signal: 'SoundRecorder: unable to connect to sound input device'].
self primSetRecordLevel: (1000.0 * recordLevel) asInteger.
recordProcess := [self recordLoop] newProcess.
recordProcess priority: Processor userInterruptPriority.
recordProcess resume!
Chris Muller uploaded a new version of Morphic to project The Trunk:
http://source.squeak.org/trunk/Morphic-cmm.1116.mcz
==================== Summary ====================
Name: Morphic-cmm.1116
Author: cmm
Time: 18 April 2016, 6:38:47.481742 pm
UUID: ae46aa73-c96e-41c2-888f-9d3fe8e1b924
Ancestors: Morphic-mt.1115
- Use the "isControlled" variable to instead indicate whether it came from a mouse move event. This proves useful to at least one model for implementing a desired UI behavior.
- For vertical smart-splitters, don't let any single line complain any more than 10-characters worth of occlusion, so that extra long lines of a list will not over-dominate the adjacent widgets.
=============== Diff against Morphic-mt.1115 ===============
Item was changed:
----- Method: AlternatePluggableListMorphOfMany>>mouseMove: (in category 'event handling') -----
mouseMove: event
"The mouse has moved, as characterized by the event provided. Adjust the scrollbar, and alter the selection as appropriate"
| oldIndex oldVal row |
event position y < self top
ifTrue:
[scrollBar scrollUp: 1.
row := self rowAtLocation: scroller topLeft + (1 @ 1)]
ifFalse:
[row := event position y > self bottom
ifTrue:
[scrollBar scrollDown: 1.
self rowAtLocation: scroller bottomLeft + (1 @ -1)]
ifFalse: [ self rowAtLocation: event position]].
row = 0 ifTrue: [^super mouseDown: event].
model okToChange ifFalse: [^self]. "No change if model is locked"
"Set meaning for subsequent dragging of selection"
oldIndex := self getCurrentSelectionIndex.
oldIndex ~= 0 ifTrue: [oldVal := self listSelectionAt: oldIndex].
"Need to restore the old one, due to how model works, and set new one."
oldIndex ~= 0 ifTrue: [self listSelectionAt: oldIndex put: oldVal].
"Inform model of selected item and let it toggle."
self
changeModelSelection: (self modelIndexFor: row)
shifted: true
+ controlled: true.
- controlled: event controlKeyPressed.
submorphs do: [:each | each changed]!
Item was changed:
----- Method: PluggableListMorph>>charactersOccluded (in category 'geometry') -----
charactersOccluded
"Answer the number of characters occluded in my #visibleList by my right edge."
| listIndex | listIndex:=0.
^ self visibleList
inject: 0
into:
[ : sum : each | | eachString totalWidth indexOfLastVisible iconWidth |
totalWidth:=0.
eachString := each asString "withBlanksTrimmed".
iconWidth := (self iconAt: (listIndex := listIndex+1)) ifNil:[0] ifNotNil: [ : icon | icon width+2 ].
indexOfLastVisible := ((1 to: eachString size)
detect:
[ : stringIndex | (totalWidth:=totalWidth+(self font widthOf: (eachString at: stringIndex))) >
(self width -
(scrollBar
ifNil: [ 0 ]
ifNotNil: [ scrollBar width ]) - iconWidth) ]
ifNone: [ eachString size + 1 ]) - 1.
+ sum + ((eachString size - indexOfLastVisible) min: 10) ]!
- sum + (eachString size - indexOfLastVisible) ]!
Hi Holger,
I ran the Shootout benchmarks[1] which I'd recently updated on
cogspurlinuxht 3397 and 3648 using the latest Squeak Trunk image, and the
latter performed better in three benchmarks: reverseComplement (-20%),
pidigits (-30%) and fasta (-40%).
For the rest, the performance of the two VMs were the same.
So, I suspect there's an area not covered by these benchmarks where you
experience the slowdown. Or there's some other difference responsible for
the slowdown.
Can you tell us more about your benchmark?
Have you tried profiling it?
Levente
[1] http://leves.web.elte.hu/squeak/Shootout-ul.19.mcz
Levente Uzonyi uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ul.819.mcz
==================== Summary ====================
Name: System-ul.819
Author: ul
Time: 26 April 2016, 2:01:42.418403 am
UUID: 0bfbfa2e-33dc-438d-90c1-813150917dac
Ancestors: System-mt.818
Added DummyStream >> #next:putAll:startingAt:.
=============== Diff against System-mt.818 ===============
Item was added:
+ ----- Method: DummyStream>>next:putAll:startingAt: (in category 'accessing') -----
+ next: anInteger putAll: aCollection startingAt: anInteger3
+
+ ^aCollection!