MVC Sound Recording

Mark Guzdial guzdial at cc.gatech.edu
Sat Jan 24 21:13:35 UTC 1998


As my first try at an MVC application from scratch, I decided to try a port
of the Morphic RecorderControls to MVC.  The result was small (but
functional!), so I'm attaching it below.

I have some questions about it that I'm hoping some of the Squeak-gurus
might be able to help me with:
- Easiest one (I think): I can't figure out how to size the window upon
opening!  I tried several different methods and none matched my
expectations.  Sometimes I got an ultra-small window with a normal size
title bar.  Other times I got a see-through window with my buttons in the
middle.  Inside Smalltalk Vol. 2 didn't help because some of their
recommended methods aren't in Squeak (e.g.,
StandardSystemView>>addView:in:borderWidth:).

- When I click the recording button, there is often a pause before
recording actually begins.  Is there something I can test to indicate that
the recorder is on so that I can display an appropriate signal?

- Finally, the "]style[" indicator showed up in the fileout from 1.3.  Is
there a way of preventing that, so that the fileOut is 1.23-compatible, or
do I just edit it out?

Thank you!
  Mark

------------- FileOut Follows ----
Object subclass: #Recorder
        instanceVariableNames: 'recorder '
        classVariableNames: ''
        poolDictionaries: ''
        category: 'MVC-Recorder'!

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 19:58'!
initialize
        recorder _ SoundRecorder new.
!
]style[(42)f1b! !

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 19:58'!
pause

        recorder pause.
! !

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 19:58'!
playback

        recorder pause.
        recorder playback.
! !

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 19:57'!
record

        recorder clearRecordedSound.
        recorder resumeRecording.
! !

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 20:00'!
saveTo: filename
        |f|
        f _ ReferenceStream fileNamed: filename.
        f nextPut:              (SampledSound
                        samples: recorder condensedSamples
                        samplingRate: recorder samplingRate).
        f close.! !

!Recorder methodsFor: 'all' stamp: 'mjg 1/23/98 19:59'!
stop

        recorder stopRecording.
! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

Recorder class
        instanceVariableNames: ''!

!Recorder class methodsFor: 'opening' stamp: 'mjg 1/24/98 09:47'!
open
        | topView aButton rec |
        rec _ self new initialize.
        topView _ StandardSystemView new
        label: 'Sound Recorder'.
        aButton _ Button newOff onAction: [rec record].
        topView addSubView: (SwitchView new
                label: 'Record' asParagraph;
                insideColor: Color gray;
                model: aButton; borderWidth: 1) viewport: (0 at 0 corner: (1/3)@1).
        aButton _ Button newOff onAction: [rec stop].
        topView addSubView: (SwitchView new
                label: 'Stop' asParagraph;
                insideColor: Color gray;
                model: aButton; borderWidth: 1) viewport: ((1/3)@0 corner:
(2/3)@1).
        aButton _ Button newOff onAction: [rec playback].
        topView addSubView: (SwitchView new
                label: 'Play' asParagraph;
                insideColor: Color gray;
                model: aButton; borderWidth: 1) viewport: (((2/3)@0)
corner: (1 at 1)).
        topView minimumSize: 50 @ 25.
        "topView window: (0 at 0 extent: 75 at 50) viewport: (0 at 0 extent: 75 at 50)."
        topView controller open.! !

--------------------------
Mark Guzdial : Georgia Tech : College of Computing : Atlanta, GA 30332-0280
(404) 894-5618 : Fax (404) 894-0673 : guzdial at cc.gatech.edu
http://www.cc.gatech.edu/gvu/people/Faculty/Mark.Guzdial.html





More information about the Squeak-dev mailing list