Using ‘random’ numbers Some ways the standard UNIX ‘rand()’ library-function can be deployed to generate graphics and sound.

Slides:



Advertisements
Similar presentations
3.01C Multimedia Elements and Guidelines 3.01 Explore multimedia systems, elements and presentations.
Advertisements

Multimedia: Digitised Sound Data Section 3. Sound in Multimedia Types: Voice Overs Special Effects Musical Backdrops Sound can make multimedia presentations.
Sampled Audio. We store digitised audio samples. This is the main audio data. In a file (e.g..wav format) we also need some header information. We will.
Sound can make multimedia presentations dynamic and interesting.
1. Digitization of Sound What is Sound? Sound is a wave phenomenon like light, but is macroscopic and involves molecules of air being compressed and expanded.
Technology ICT Option: Data Representation. Data Representation In our everyday lives, we communicate with each other using analogue data. This data takes.
VGA Text Mode An introduction to font selection and to reprogramming of the Character Generator ram.
Audio 2 Subject:T0934 / Multimedia Programming Foundation Session:9 Tahun:2009 Versi:1/0.
I Power Higher Computing Multimedia technology Audio.
1 Random number generation Using srand(), rand() & time(0) Searching and Sorting Demo Making searching & sorting more generic Overloading the functions.
Audio Basic Concepts. Audio in Multimedia Digital Audio: Sound that has been captured or created electronically by a computer In a multimedia production,
CS 686: Programming SuperVGA Graphics Devices Introduction: An exercise in working with graphics file formats.
Graphics Bitmaps Drawing alphabetic characters and multicolor patterns.
1 Digital Audio Storage Formats. 2 Formats  There are many different formats for storing and communicating digital audio:  CD audio  Wav  Aiff  Au.
MPEG-3 For Audio Presented by: Chun Lui Sunjeev Sikand.
Graphics Bitmaps Drawing characters glyphs and multicolor patterns.
Graphics File Formats. 2 Graphics Data n Vector data –Lines –Polygons –Curves n Bitmap data –Array of pixels –Numerical values corresponding to gray-
Speech Detection Project 1. Outline Motivation Problem Statement Details Hints.
IT-Academic Technology Services Using Microsoft PowerPoint 2010 for Digital Storytelling.
Representation of Data in Computer Systems
Chapter 5 Data representation.
Media File Formats Jon Ivins, DMU. Text Files n Two types n 1. Plain text (unformatted) u ASCII Character set is most common u 7 bits are used u This.
GODIAN MABINDAH RUTHERFORD UNUSI RICHARD MWANGI.  Differential coding operates by making numbers small. This is a major goal in compression technology:
COMP Representing Sound in a ComputerSound Course book - pages
Digital Music to Sheet Music Hugh Smith. Abstract Electronic music has been steadily expand- ing over the past years. Many file formats have come into.
Multimedia I (Audio/Video Data) CS423, Fall 2007 Klara Nahrstedt/Sam King 9/19/20151.
By Danny Matthews Supervised by Dr Des Watson. “ A very precise form of simulation which enables one type of computer to operate as if it were a different.
ECE291 Computer Engineering II Lecture 9 Josh Potts University of Illinois at Urbana- Champaign.
Chapter 2 Computer Hardware
By Sidhant Garg.  C was developed between by Dennis Ritchie at Bell Laboratories for use with the Unix Operating System.  Unlike previously.
AUDIO MEDIA 1 Created } “Borrowed” } Microphone MIDI keyboard CD’s & flash drives Internet Audio Sources 2.
Signal Digitization Analog vs Digital Signals An Analog Signal A Digital Signal What type of signal do we encounter in nature?
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
Anatomy of a Sound File v © Allan C. Milne Abertay University.
Digital Sound Actual representation of sound Stored in form of thousands of individual numbers (called samples) Not device dependent Stored in bits.
Lecture-5 Miscellaneous. Random Numbers Can use ‘rand()’ function declared in the stdlib.h header file The seed for random number generation can be set.
Digital Music to Sheet Music Hugh Smith. Abstract Electronic music has been steadily expand- ing over the past years. Many file formats have come into.
By Danny Matthews Supervised by Dr Des Watson. 8 Bit 8 Bit console released in Million 60 Million Units Sold 1000 Released Titles Over 1000 Released.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
Marwan Al-Namari 1 Digital Representations. Bits and Bytes Devices can only be in one of two states 0 or 1, yes or no, on or off, … Bit: a unit of data.
Media Types Information Systems can contain the following types of media: Sound, graphics, video & text.
Multimedia and weBLOGging Grade 7-9 | Cahaya Bangsa Classical School (C) 2010 Digital Media Production Facility 04 – Audio Basic.
Digital Audio III. Sound compression (I) Compression of sound data requires different techniques from those for graphical data Requirements are less stringent.
CSCI-100 Introduction to Computing Hardware Part II.
Guerino Mazzola (Fall 2015 © ): Introduction to Music Technology IIIDigital Audio III.5 (F Oct 30) MP3 and other digital audio file formats.
Data Representation. What is data? Data is information that has been translated into a form that is more convenient to process As information take different.
Audio Streaming © Nanda Ganesan, Ph.D.. Audio File Features Audio file is a record of captured sound that can be played back –The WAV File is an example.
Analog vs Digital Music Should I Change?. Digital Music Presentation DIGITAL RECORDING  For full detail on Digital recording Visit: 
Data Types Always data types will decide which type of information we are storing into variables In C programming language we are having 3 types of basic.
Audio Definition Model for Flexible File Formats Dave Marston BBC R&D.
Graphics and Image Data Representations 1. Q1 How images are represented in a computer system? 2.
Lecture 11 Text mode video
Creating cast members  Using tool palette window that can be selected from window menu.  The following objects can be created: Push buttons, Radio buttons,
Data Representation. In our everyday lives, we communicate with each other using analogue data. This data takes the form of: Sound Images Letters Numbers.
Yongchang, Kai, Justin, Rama
GCSE COMPUTER SCIENCE Topic 3 - Data 3.2 Data Representation.
‘C’ Programming Structures and Commands
Level 3 Extended Diploma Unit 19 Computer Systems Architecture
Level 3 Extended Diploma Unit 19 Computer Systems Architecture
Binary Representation in Audio and Images
III Digital Audio III.5 (W Oct 18) MP3 and other digital audio file formats.
Multimedia: Digitised Sound Data
Microprocessor and Assembly Language
INTRODUCTION c is a general purpose language which is very closely associated with UNIX for which it was developed in Bell Laboratories. Most of the programs.
Hyperlinks, Images and Tables
Variables ,Data Types and Constants
Images in Binary.
Ch2: Data Representation
Hyperlinks, Images and Tables
Networks & I/O Devices July 10, 2019.
Presentation transcript:

Using ‘random’ numbers Some ways the standard UNIX ‘rand()’ library-function can be deployed to generate graphics and sound

Automating pattern creation Use these standard runtime functions; –#include –int rand( void ); –void srand( unsigned int seed ); Make a new 8x8 bitmap pattern like this: unsigned charpat[ 8 ]; for (k = 0; k < 8; k++) pat[ k ] = rand(); fgcolor = rand(); bgcolor = rand();

Esthetics Use a ‘brighter’ color in the foreground Use a ‘darker’ color in the background To implement this discipline we need to know how the ‘color-table’ is arranged In mode 19 there are 256 default colors Among these are 24 color-groups: –3 intensity-levels plus 3 saturation-levels

The ‘default’ colors (mode 19) Range for the 72 brightest colors: 32–103 Range for the 72 midlevel colors: Range for the 72 darkest colors: Colors 0-15 are the standard EGA colors Colors are sixteen grayscale colors Colors are solid black (default) (But all of these are fully ‘programmable’)

Choosing a random color-pair foreground color (from the ‘bright’ range): fgcolor = ( ( rand() & 0xFF ) % 72 ) + 32; Background color (from the ‘dark’ range): bgcolor = ( ( rand() & 0xFF ) % 72 ) + 104;

Using patterns with more colors Same concepts can be extended But need a larger pattern-bitmap Example: use 2 bits-per-pixel (4 colors) An 8x8 pattern that using 4 colors: unsigned shortpat2bpp[ 8 ]; unsigned charpalette4[ 4 ]; for (r = 0; r < 8; r++) pat2bpp[ r ] = rand(); for (c = 0; c < 4; c++) palette4[ c ] = rand();

Tiling with a 4-color bitmap for (y = 0; y < hres; y++) { unsigned shortbits = pat2bpp[ y % 8 ]; for (x = 0; x < hres; x++) { inti = ( bits >> ( x % 8 )&3; intcolor = palette4[ i ]; vram[ y*hres + x ] = color; }

Automating an ‘art show’ Can use a standard C runtime function: #include void sleep( int seconds ); User views your screen for fixed duration: while ( !done ) { draw_next_scene(); sleep(1); }

In-class exercise #1 Can you use the UNIX random-number generator function to create an art show (i.e., a succession of esthetically pleasing patterns that tile the display screen for a timed duration)?

Generating ‘white noise’ We can use the ‘rand()’ function to create pulse-code data for a Waveform Audio file When we play that.wav file what we will hear is a sound known as ‘white noise’ Let’s look at the details for IBM/Microsoft Waveform Audio file-format (.wav) – their original ‘simple’ version (Version 1.0) It’s contents is organized into ‘chunks’

The Waveform Audio-File Format RIFF Chunk (12 bytes) FORMAT Chunk (24 bytes) DATA Chunk (size varies) Version 1.0 Developed jointly in 1991 by IBM and Microsoft Corporation for the Windows 3.1 operating system

The RIFF chunk “RIFF” Total number of the file’s bytes that follow “WAVE” chunkName chunkSize chunkType (ascii characters) (unsigned int) (ascii characters) 12 bytes RIFF = “Resource Interchange File Format” Remainder of the RIFF chunk holds all the file’s other chunks

The FORMAT chunk “fmt “ (ascii characters) Number of chunk’s bytes that follow (i.e., 16) samplesPerSec (e.g., 44100) avBytesPerSec formatTag (i.e., 0 or 1) nChannels (mono=1 or stereo=2) frameAlignmt (i.e., 1, 2, 4) bitsPerSample (e.g., 8 or 16) Originally was a fixed size: header (8 bytes) plus parameters (16 bytes) TOTAL SIZE = 24 bytes

The DATA chunk “data“ (ascii characters) Number of chunk’s bytes that follow (i.e., 16) The PCM data goes here (Pulse Code Modulation) size is variable

8-Bit Sample Formats 8-bit monoaural: Each sample is one byte –Value is an ‘unsigned char’ in range –The ‘neutral’ value is 128 (i.e., silence) 8-bit stereo: Each sample is a byte-pair –First sample-value is for left-hand channel, second sample-value is right-hand channel

16-Bit Sample Formats 16-bit monoaural: sample-size is two bytes –Value is a ‘short’ in range –The default storage-convention is ‘Big-Endian’ –The neutral value is 0 (i.e., silence) 16-bit stereo: sample-size is four bytes –First sample-value is for left-hand channel, second sample-value is right-hand channel

Our ‘mknoises.cpp’ demo Program creates a file named ‘noises.wav’ It demonstrates stereophonic ‘white noise’ –First the left-hand channel plays white noise –Then right-hand channel plays white noise Uses ‘8-bit stereo’ sample-format: Left-channel pulse-codeRight-channel pulse-code Each ‘sample’ stores a pair of 8-bit pulse-code values

In-class exercise #2 Can you modify the ‘mknoises.cpp’ demo so that noise from the left-hand channel gradually diminishes in volume while the noise from the right-channel is gradually getting louder?