ugBASIC 1.18
An isomorphic BASIC language compiler for retrocomputers
Loading...
Searching...
No Matches
envelope.c
Go to the documentation of this file.
1/*****************************************************************************
2 * ugBASIC - an isomorphic BASIC language compiler for retrocomputers *
3 *****************************************************************************
4 * Copyright 2021-2026 Marco Spedaletti (asimov@mclink.it)
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *----------------------------------------------------------------------------
18 * Concesso in licenza secondo i termini della Licenza Apache, versione 2.0
19 * (la "Licenza"); è proibito usare questo file se non in conformità alla
20 * Licenza. Una copia della Licenza è disponibile all'indirizzo:
21 *
22 * http://www.apache.org/licenses/LICENSE-2.0
23 *
24 * Se non richiesto dalla legislazione vigente o concordato per iscritto,
25 * il software distribuito nei termini della Licenza è distribuito
26 * "COSÌ COM'È", SENZA GARANZIE O CONDIZIONI DI ALCUN TIPO, esplicite o
27 * implicite. Consultare la Licenza per il testo specifico che regola le
28 * autorizzazioni e le limitazioni previste dalla medesima.
29 ****************************************************************************/
30
31/****************************************************************************
32 * INCLUDE SECTION
33 ****************************************************************************/
34
35#include "../../../ugbc.h"
36
37/****************************************************************************
38 * CODE SECTION
39 ****************************************************************************/
40
41#if defined(__c128__) || defined(__c64__) || defined(__c64reu__)
42
43/* <usermanual>
44@keyword ENVELOPE
45
46@english
47
48The ''ENVELOPE'' command is used to define the volume of a sound over
49time, or its envelope. In simpler terms, it allows you to create
50richer and more complex sound effects, by defining the initial phase
51in which the sound rapidly increases in volume, the phase in which
52the sound decreases in volume, the final phase in which the sound
53fades away until it disappears. The ''ENVELOPE'' command uses
54internal tone generators to create these effects.
55
56This command simulates different musical instruments, such as
57pianos, drums, sound effects, and more. It creates more complex
58and dynamic melodies and harmonies, and it can be used to
59create sound effects for games, such as explosions,
60gunshots, or ambient sounds.
61
62@italian
63
64Il comando ''ENVELOPE'' viene utilizzato per definire il volume
65di un suono nel tempo, o il suo envelope. In termini più semplici,
66consente di creare effetti sonori più ricchi e complessi, definendo
67la fase iniziale in cui il suono aumenta rapidamente di volume, la
68fase in cui il suono diminuisce di volume, la fase finale in cui
69il suono si affievolisce fino a scomparire. Il comando ''ENVELOPE''
70utilizza generatori di toni interni per creare questi effetti.
71
72Questo comando simula diversi strumenti musicali, come pianoforti,
73tamburi, effetti sonori e altro ancora. Crea melodie e armonie più
74complesse e dinamiche e può essere utilizzato per creare effetti
75sonori per i giochi, come esplosioni, spari o suoni ambientali.
76
77@syntax ENVELOPE voice, attack, decay, sustain, release
78
79@example ENVELOPE 1, 2, 11, 5, 0
80
81</usermanual> */
82
83
84void envelope( Environment * _environment, char * _voice, char * _attack, char * _decay, char * _sustain, char * _release ) {
85
86 Variable * voice = variable_retrieve_or_define( _environment, _voice, VT_BYTE, 0x7 );
87 Variable * attack = variable_retrieve_or_define( _environment, _attack, VT_BYTE, 0 );
88 Variable * decay = variable_retrieve_or_define( _environment, _decay, VT_BYTE, 0 );
89 Variable * sustain = variable_retrieve_or_define( _environment, _sustain, VT_BYTE, 0 );
90 Variable * release = variable_retrieve_or_define( _environment, _release, VT_BYTE, 0 );
91
92 sid_attack_decay_sustain_release( _environment, voice->realName, attack->realName, decay->realName, sustain->realName, release->realName );
93
94}
95
96#endif
Variable * variable_retrieve_or_define(Environment *_environment, char *_name, VariableType _type, int _value)
void envelope(Environment *_environment, char *_voice, char *_attack, char *_decay, char *_sustain, char *_release)
Definition envelope.c:41
void sid_attack_decay_sustain_release(Environment *_environment, char *_voice, char *_attack, char *_decay, char *_sustain, char *_release)
Definition sid.c:264
char * realName
Definition ugbc.h:982
struct _Variable Variable
Structure of a single variable.
struct _Environment Environment
Structure of compilation environment.
@ VT_BYTE
Definition ugbc.h:450