610 |
608 |
611 "Created: 17.11.1995 / 17:27:26 / cg" |
609 "Created: 17.11.1995 / 17:27:26 / cg" |
612 "Modified: 17.11.1995 / 17:47:13 / cg" |
610 "Modified: 17.11.1995 / 17:47:13 / cg" |
613 ! |
611 ! |
614 |
612 |
|
613 flush |
|
614 "wait until all sound has been played" |
|
615 |
|
616 %{flush |
|
617 "wait until all sound has been played" |
|
618 |
|
619 %{ |
|
620 #ifdef IR!flush |
|
621 {flush |
|
622 "wait until all sound has been played" |
|
623 |
|
624 %{ |
|
625 #ifdef IRIS_AUDIO |
|
626 ALpor{flush |
|
627 "wait until all sound }flush}flush |
|
628 "wait until all s}flush |
|
629 "wait until all sound has been played" |
|
630 |
|
631 %{ |
|
632 #ifdef IRIS_AUD! |
|
633 |
615 nextBytes:count into:anObject startingAt:start |
634 nextBytes:count into:anObject startingAt:start |
|
635 "read the next count bytes into an object and return the number of |
|
636 bytes read or nil on error. |
|
637 Use with ByteArrays only." |
|
638 |
|
639 %{nextBytes:count into:{nextBytes:count into:anObject startingAt:start |
|
640 "read the next count bytes into an object a!nextByt{nextBytes:count int!nextBytes:coun{nextBytes:count into:anObject startingAt:sta{nextBytes:count into:anObject startingAt:start |
|
641 "read the next count bytes into an object and return the number of |
|
642 bytes read or nil on error. |
|
643 Use with ByteArrays only." |
|
644 |
|
645 %{ |
|
646 #ifdef IR{nextBytes:count into:anObject startingAt:start |
|
647 "read the next count bytes into an object and return the number of |
|
648 bytes read or nil on error. |
|
649 Use with ByteArrays only." |
|
650 |
|
651 %{ |
|
652 #ifdef IRIS_AUDIO |
|
653 { |
|
654 ALport p;}nextBy}ne}nextB}nex}nextBytes}nextBytes:count into:anObject startingAt:start |
616 "read the next count bytes into an object and return the number of |
655 "read the next count bytes into an object and return the number of |
617 bytes read or nil on error. |
656 bytes read or nil on error. |
618 Use with ByteArrays only." |
657 Use with ByteArrays only." |
619 |
658 |
620 %{ |
659 %{ |
621 #ifdef IRIS_AUDIO |
660 #ifdef IRIS_AUDIO |
622 { |
661 { |
623 ALport p; |
662 ALport p; |
624 int cnt, offs; |
663 int cnt, offs; |
625 int objSize; |
664 int ob! |
626 char *cp; |
|
627 |
|
628 if (__INST(filePointer) != nil) { |
|
629 if (__INST(mode) != _writeonly) { |
|
630 if (__bothSmallInteger(count, start)) { |
|
631 cnt = _intVal(count); |
|
632 offs = _intVal(start) - 1; |
|
633 p = _ALportVal(__INST(filePointer)); |
|
634 objSize = _Size(anObject) - OHDR_SIZE; |
|
635 if ((offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs))) { |
|
636 cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; |
|
637 if (__INST(bitsPerSample) == __MKSMALLINT(16)) |
|
638 ALreadsamps(p, cp, cnt / 2); |
|
639 else |
|
640 ALreadsamps(p, cp, cnt); |
|
641 RETURN ( __MKSMALLINT(cnt) ); |
|
642 } |
|
643 } |
|
644 } |
|
645 } |
|
646 } |
|
647 #endif |
|
648 %} |
|
649 . |
|
650 OperatingSystem getOSType = 'irix' ifFalse:[ |
|
651 ^ super nextPutBytes:count from:anObject startingAt:start |
|
652 ]. |
|
653 filePointer isNil ifTrue:[^ self errorNotOpen]. |
|
654 (mode == #writeonly) ifTrue:[^ self errorWriteOnly]. |
|
655 self primitiveFailed |
|
656 ! |
|
657 |
665 |
658 nextPutBytes:count from:anObject startingAt:start |
666 nextPutBytes:count from:anObject startingAt:start |
659 "write count bytes from an object starting at index start. |
667 "write count bytes from an object starting at index start. |
660 return the number of bytes written or nil on error. |
668 return the number of bytes written or nil on error. |
661 Redefined, since IRIS audio library cannot be used with stdio. |
669 Redefined, since IRIS audio library cannot be used with stdio. |
662 (at least I dont know). Use with ByteArrays only." |
670 (at least I dont know). Use with ByteArrays only." |
663 |
671 |
664 %{ |
672 %{nextPutBytes:count fr{nextPutBytes:count from:anObject startingAt:start |
665 #ifdef IRIS_AUDIO |
673 "write count bytes from an object starti!nextPut{nextPutBytes:count !nextPutBytes:{nextPutBytes:count from:anObject startingAt:{nextPutBytes:count from:anObject startingAt:start |
666 { |
674 "write count bytes from an object starting at index start. |
667 ALport p; |
675 return the number of bytes written or nil on error. |
668 int cnt, offs; |
676 Redefined, since IRIS audio library cannot be used with stdio. |
669 int objSize; |
677 {nextPutBytes:count from:anObject startingAt:start |
670 char *cp; |
678 "write count bytes from an object starting at index start. |
671 |
679 return the number of bytes written or nil on error. |
672 if (__INST(filePointer) != nil) { |
680 Redefined, since IRIS audio library cannot be use}nextPu}ne}nextP}nex}nextPutBy}nextPutBytes:count from:anObject startingAt:start |
673 if (__INST(mode) != _readonly) { |
681 "write count bytes from an object starting at index start. |
674 if (__bothSmallInteger(count, start)) { |
682 return the number of bytes written or nil on error. |
675 cnt = _intVal(count); |
683 Redefined, since IRIS audio library cannot be used with stdio. |
676 offs = _intVal(start) - 1; |
684 (at lea! |
677 p = _ALportVal(__INST(filePointer)); |
685 |
678 |
686 openWithMode:aMode |
679 /* |
|
680 * compute number of samples |
|
681 */ |
|
682 objSize = _Size(anObject) - OHDR_SIZE; |
|
683 if ( (offs >= 0) && (cnt >= 0) && (objSize >= (cnt + offs)) ) { |
|
684 cp = (char *)__InstPtr(anObject) + OHDR_SIZE + offs; |
|
685 if (__INST(bitsPerSample) == __MKSMALLINT(16)) |
|
686 ALwritesamps(p, cp, cnt / 2); |
|
687 else |
|
688 ALwritesamps(p, cp, cnt); |
|
689 RETURN ( __MKSMALLINT(cnt) ); |
|
690 } |
|
691 } |
|
692 } |
|
693 } |
|
694 } |
|
695 #endif |
|
696 %} |
|
697 . |
|
698 OperatingSystem getOSType = 'irix' ifFalse:[ |
687 OperatingSystem getOSType = 'irix' ifFalse:[ |
699 ^ super nextPutBytes:count from:anObject startingAt:start |
688 "its a regular file open" |
700 ]. |
689 ^ super openWithMode:aMode |
701 filePointer isNil ifTrue:[^ self errorNotOpen]. |
690 ]. |
702 (mode == #readonly) ifTrue:[^ self errorReadOnly]. |
691 |
703 self primitiveFailed |
692 ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ |
704 ! |
693 self error:'invalid mode'. |
705 |
694 ^ nil |
706 openWithMode:aMode |
695 ]. |
|
696 %{openWithMode:aMode |
|
697 {openWithMode:aMode |
|
698 OperatingSystem getOSType = 'irix{openWithMode:aMode |
|
699 OperatingSystem getOSType = 'irix' ifFalse:[ |
|
700 "its a regula}openWithMode:aMode |
707 OperatingSystem getOSType = 'irix' ifFalse:[ |
701 OperatingSystem getOSType = 'irix' ifFalse:[ |
708 "its a regular file open" |
702 "its a regular file open" |
709 ^ super openWithMode:aMode |
703 ^ super openWithMode:aMode |
710 ]. |
704 ]. |
711 |
705 |
726 |
720 |
727 config = ALnewconfig(); |
721 config = ALnewconfig(); |
728 if (__INST(numberOfChannels) == __MKSMALLINT(2)) |
722 if (__INST(numberOfChannels) == __MKSMALLINT(2)) |
729 ALsetchannels(config, AL_STEREO); |
723 ALsetchannels(config, AL_STEREO); |
730 else |
724 else |
731 ALsetchannels(config, AL_MONO); |
725 ALset{openWithMode:aMode |
732 if (__INST(bitsPerSample) == __MKSMALLINT(16)) |
726 OperatingSystem g}openWi{openWithMode:aMode |
733 ALsetwidth(config, AL_SAMPLE_16); |
727 OperatingSystem getOSType}openWithMode:aMode |
734 else |
728 OperatingSystem getOSType = 'irix' ifFalse:[ |
735 ALsetwidth(config, AL_SAMPLE_8); |
729 "its a regular file open" |
736 |
730 ^ super openWithMode:aMode |
737 if (__isSmallInteger(__INST(sampleRate))) |
731 ]. |
738 params[3] = params[5] = _intVal(__INST(sampleRate)); |
732 |
739 |
733 ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ |
740 ALsetparams(AL_DEFAULT_DEVICE, params, 6); |
734 {openWithMode:aMode |
741 p = ALopenport("smallchat", (char *)_stringVal(aMode), config); |
735 OperatingSystem getOSType = 'irix' ifFalse:[ |
742 if (p) { |
736 "its a regular file open" |
743 __INST(filePointer) = __MKOBJ(p); |
737 ^ super openWithMode:aMode |
744 } else { |
738 ]. |
745 __INST(filePointer) = nil; |
739 |
746 RETURN (nil); |
740 ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ |
747 } |
741 self error:'inv}openWithMode:aMode |
748 __INST(binary) = true; |
742 OperatingS{openWithMode:aMode |
749 |
743 OperatingSystem getOSType = 'irix' ifFalse:[ |
750 ALfreeconfig(config); |
744 "its a regular file open" |
751 /* |
745 ^ super openWithMode:aMode |
752 * get the parameters actually installed |
746 ]. |
753 */ |
747 |
754 config = ALgetconfig(p); |
748 ((aMode = 'r') or:[aMode = 'w']) ifFalse:[ |
755 switch (ALgetchannels(config)) { |
749 self error:'invalid mode'. |
756 default: |
750 ^ nil |
757 /* cannot happen */ |
751 ]. |
758 case AL_MONO: |
752 %{ |
759 __INST(numberOfChannels) = __MKSMALLINT(1); |
|
760 break; |
|
761 case AL_STEREO: |
|
762 __INST(numberOfChannels) = __MKSMALLINT(2); |
|
763 break; |
|
764 } |
|
765 switch (ALgetwidth(config)) { |
|
766 default: |
|
767 /* cannot happen */ |
|
768 case AL_SAMPLE_8: |
|
769 __INST(bitsPerSample) = __MKSMALLINT(8); |
|
770 break; |
|
771 case AL_SAMPLE_16: |
|
772 __INST(bitsPerSample) = __MKSMALLINT(16); |
|
773 break; |
|
774 case AL_SAMPLE_24: |
|
775 __INST(bitsPerSample) = __MKSMALLINT(24); |
|
776 break; |
|
777 } |
|
778 ALgetparams(AL_DEFAULT_DEVICE, params, 6); |
|
779 __INST(sampleRate) = __MKSMALLINT(params[3]); |
|
780 |
|
781 ALfreeconfig(config); |
|
782 } |
|
783 #endif |
|
784 %} |
|
785 . |
|
786 ^ self |
|
787 ! |
|
788 |
|
789 synchronizeOutput |
|
790 "wait until all sound has been played" |
|
791 |
|
792 %{ |
|
793 #ifdef IRIS_AUDIO |
753 #ifdef IRIS_AUDIO |
794 ALport p; |
754 { |
795 |
755 ALconfig config; |
796 if (__INST(filePointer) != nil) { |
756 ALpor}openWithMode:aMode |
797 p = _ALportVal(__INST(filePointer)); |
|
798 while (ALgetfilled(p) > 0) { |
|
799 sginap(1); |
|
800 } |
|
801 } |
|
802 #endif |
|
803 %} |
|
804 . |
|
805 OperatingSystem getOSType = 'irix' ifFalse:[ |
757 OperatingSystem getOSType = 'irix' ifFalse:[ |
806 "dont know how to wait" |
758 "its a regular file open" |
807 ]. |
759 ^ super openWithMode:aMode |
808 ^ self |
760 }openWithM}openWithMode:a! ! |
809 ! ! |
|
810 |
761 |
811 !SoundStream methodsFor:'sine wave generation'! |
762 !SoundStream methodsFor:'sine wave generation'! |
812 |
763 |
813 tuneTone |
764 tuneTone |
814 |buffer numSamples val scale| |
765 |buffer numSamples val scale| |