This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:tutorials:audio:sound [2012/03/01 10:28 (11 years ago)] zera [Summary] |
en:tutorials:audio:sound [2020/08/31 08:31 (24 months ago)] (current) 40.77.167.232 ↷ Links adapted because of a move operation |
||
---|---|---|---|
Line 3: | Line 3: | ||
===== Summary ===== | ===== Summary ===== | ||
- | Ver los anteriores [[main#Basic|tutoriales básicos]] para más información sobre la [[object|creación básica de objetos]], [[clock|manejo del reloj]], [[frame|jerarquía de fotogramas]], [[anim|animaciones]] y [[viewport|cámaras & vistas]]. | + | See previous basic tutorials for more info about basic [[..:objects:object|object creation]], [[..:clocks:clock|clock handling]], [[..:objects:frame|frames hierarchy]], [[..:animation:anim|animations]] and [[..:viewport:viewport|cameras & viewports]]. |
- | Este tutorial muestra como reproducir sonidos(muestras) y músicas(streams).\\ | + | This tutorial shows how to play sounds (samples) and musics (streams).\\ |
- | Como con otras características de comportamientos anteriores, solo se requiere, la mayoría de las veces, una sola linea de código, para empezar a manejar todos los datos.\\ | + | As with other features from previous behavior, it only requires, most of the time, a single line of code, everything being data driven.\\ |
- | Este tutorial también demuestra como alterar las configuraciones del sonido en tiempo real, usando el gráfico del soldado como retroalimentación visual. | + | This tutorial also demonstrates how to alter sound settings in real time, using the soldier graphic as a visual feedback. |
- | Si tu presionas las flechas arriba & abajo, el volumen de la música cambiará acordemente. El soldado se escalará como consecuencia.\\ | + | If you press up & down arrows, the music volume will change accordingly. The soldier will be scale in consequence.\\ |
- | Por presionar las flechas izquierda & derecha, el tono de la música(frecuencia) cambiará. El soldado rotara como una perilla. | + | By pressing left & right arrows, the music pitch (frequency) will change. The soldier will rotate like a knob.\\ |
- | La tecla Control Izquierda reproducirá la música(y activará el soldado) si la música fue pausada, de otra manera pausará la música(y desactivará el soldado).\\ | + | Left control key will play the music (and activate the soldier) if the music was paused, otherwise it'll pause the music (and deactivate the soldier).\\ |
- | El efecto de sonido de la tecla Espacio presionada es la misma que Enter, excepto, de que su volumen y tono son aleatoriamente definidos en fichero de configuración por defecto. | + | Lastly, enter and space will play a sound effect on the soldier.\\ |
+ | Space triggered sound effect is the same as enter except that its volume and pitch are randomly defined in the default config file. | ||
- | Esta aleatoriedad de la frecuencia controlada en la configuración permite fácilmente generar de paso o golpeo de sonido con ligeras variaciones con ninguna linea adicional de código.\\ | + | This config-controlled frequency randomness allows to easily generate step or hit sounds with slight variations with no extra line of code.\\ |
- | Cambiamos aleatoriamente el color del soldado para ilustrar esto.\\ | + | We randomly change the soldier's color to illustrate this.\\ |
- | El efecto de sonido solo se añadirá y reproducirá con el soldado activo.\\ | + | The sound effect will only be added and played on an active soldier.\\ |
- | Si tu quieres reproducir un efecto de sonido sin ningun objeto como soporte, tu lo puedes hacer de la misma manera que creamos la música en este tutorial.\\ | + | If you want to play a sound effect with no object as support, you can do it the same way we create the music in this tutorial.\\ |
- | Sin embargo, reproduciendo un sonido en un objecto permitiría posicionar el sonido espacialmente(no cubierto en este tutorial). | + | However, playing a sound on an object will allow spatial sound positioning (not covered by this tutorial). |
- | Muchos efectos de sonido pueden ser reproducidos al mismo tiempo en un solo objeto. | + | Many sound effects can be played at the same time on a single object. |
- | El atributo ''KeepDataInCache'' de configuración del sonido permite mantener la muestra de sonido en la memoria en de releerlo del fichero constantemente. | + | The sound config attribute KeepDataInCache allows to keep the sound sample in memory instead of rereading it from file every time.\\ |
- | Esto solo funciona para datos no-stream(ej. No para música).\\ | + | This only works for non-streamed data (ie. not for musics).\\ |
- | Si esto fuera falso, la muestra será recargada desde fichero, a menos que no haya otro efecto de sonido del mismo tipo que esté siendo reproducido. | + | If it's set to false, the sample will be reloaded from file, unless there's currently another sound effect of the same type being played. |
- | También registramos los eventos de sonidos para mostrar cuando los efectos de sonidos son reproducidos y detenidos.\\ | + | We also register to the sound events to display when sound effects are played and stopped.\\ |
- | Estos eventos son solo enviados por efectos de sonido reproducidos en objetos. | + | These events are only sent for sound effects played on objects. |
===== Details ===== | ===== Details ===== | ||
- | As usual, we begin by loading our config file, getting the main clock and registering our ''Update'' function to it and, lastly, by creating our soldier object.\\ | + | As usual, we begin by creating a viewport, getting the main clock and registering our ''Update'' function to it and, lastly, by creating our soldier object.\\ |
- | Please refer to the [[main#Basic|previous tutorials]] for more details. | + | Please refer to the previous tutorials for more details. |
We then create a music and play it. | We then create a music and play it. | ||
Line 109: | Line 110: | ||
This simple code, when activating the input ''ToggleMusic'', will either start the music and activate our soldier if the music was not playing or, on the contrary, will stop it and deactivate our soldier if the music was playing. | This simple code, when activating the input ''ToggleMusic'', will either start the music and activate our soldier if the music was not playing or, on the contrary, will stop it and deactivate our soldier if the music was playing. | ||
- | Now, let's can change the pitch. | + | Now, let's change the pitch. |
<code c>if(orxInput_IsActive("PitchUp")) | <code c>if(orxInput_IsActive("PitchUp")) | ||
Line 129: | Line 130: | ||
Same as for the pitch, nothing unusual. | Same as for the pitch, nothing unusual. | ||
- | //NB: We can notice that only our object rotation will be time-consistent (cf. [[clock|clock tutorial]]).\\ | + | //NB: We can notice that only our object rotation will be time-consistent (cf. [[..:clocks:clock|clock tutorial]]).\\ |
The music's pitch and volume, as well as the object's scale will be framerate-dependent, which is a bad idea.\\ | The music's pitch and volume, as well as the object's scale will be framerate-dependent, which is a bad idea.\\ | ||
To fix this we'd only need to use the clock's DT to ponderate the given values.// | To fix this we'd only need to use the clock's DT to ponderate the given values.// | ||
Line 167: | Line 168: | ||
===== Resources ===== | ===== Resources ===== | ||
- | Source code: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/src/06_Sound/06_Sound.c|06_Sound.c]] | + | Source code: [[https://github.com/orx/orx/blob/master/tutorial/src/06_Sound.c|06_Sound.c]] |
- | + | ||
- | Config file: [[https://orx.svn.sourceforge.net/svnroot/orx/trunk/tutorial/bin/06_Sound.ini|06_Sound.ini]] | + | |
+ | Config file: [[https://github.com/orx/orx/blob/master/tutorial/bin/06_Sound.ini|06_Sound.ini]] |