Write a method in the Picture class to convert a Picture object into a Sound object using the average of the color values. Map all values from 0 to 84 to the maximum negative sound value, map all values from 85 to 169 to 0 and all values above 170 to the maximum positive value.

What will be an ideal response?

```
/? ?
? Method t o c o n v e r t a p i c t u r e i n t o a sound
? @return t h e r e s u l t i n g sound
?/
public Sound convertToSound ( )
{
Pixel [ ] pixelArray = this . g e t P i x e l s ( ) ;
P i x e l c u r r P i x e l = null ;
Sound aSound = new Sound ( p i x e l A r r a y . l e n g t h ) ;
// l o o p t h r o u g h p i x e l a r r a y
f o r ( i n t i = 0 ; i < p i x e l A r r a y . l e n g t h ; i ++)
{
currPixel = pixelArray [ i ] ;
double a v e r a g e = c u r r P i x e l . g e t A v e r a g e ( ) ;
// map t h e a v e r a g e t o a sound v a l u e
i f ( a v e r a g e <= 8 4 )
aSound . setSampleValueAt ( i , Sound .MAX NEG) ;
e l s e i f ( a v e r a g e <= 1 6 9 )
aSound . setSampleValueAt ( i , 0 ) ;
else
aSound . setSampleValueAt ( i , Sound .MAX POS ) ;
}
return aSound ;
}
```

Computer Science & Information Technology

You might also like to view...

What is unique about the Windows 10 operating system?

A) It will be continually updated from now on. B) It is a short-term operating system until Windows 11 is released. C) It is less efficient with touch-screen computers. D) It requires a considerably more powerful computer than Windows 8.

Computer Science & Information Technology

When shopping for music at an online music store, the customer is accessing ________ that identify files according to the recording artist, music type, song title, album title or other data

A) databases B) presentations C) documents D) spreadsheets

Computer Science & Information Technology