MCPcopy Create free account
hub / github.com/PaulStoffregen/Audio / initialize

Method initialize

effect_delay_ext.cpp:108–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106uint32_t AudioEffectDelayExternal::allocated[2] = {0, 0};
107
108void AudioEffectDelayExternal::initialize(AudioEffectDelayMemoryType_t type, uint32_t samples)
109{
110 uint32_t memsize, avail;
111
112 activemask = 0;
113 head_offset = 0;
114 memory_type = type;
115 if (type == AUDIO_MEMORY_23LC1024) {
116#ifdef INTERNAL_TEST
117 memsize = 8000;
118#else
119 memsize = 65536;
120#endif
121 pinMode(SPIRAM_CS_PIN, OUTPUT);
122 digitalWriteFast(SPIRAM_CS_PIN, HIGH);
123 } else if (type == AUDIO_MEMORY_MEMORYBOARD) {
124 memsize = 393216;
125 pinMode(MEMBOARD_CS0_PIN, OUTPUT);
126 pinMode(MEMBOARD_CS1_PIN, OUTPUT);
127 pinMode(MEMBOARD_CS2_PIN, OUTPUT);
128 digitalWriteFast(MEMBOARD_CS0_PIN, LOW);
129 digitalWriteFast(MEMBOARD_CS1_PIN, LOW);
130 digitalWriteFast(MEMBOARD_CS2_PIN, LOW);
131 } else {
132 return;
133 }
134 avail = memsize - allocated[type];
135 if (avail < AUDIO_BLOCK_SAMPLES*2+1) {
136 memory_type = AUDIO_MEMORY_UNDEFINED;
137 return;
138 }
139 if (samples > avail) samples = avail;
140 memory_begin = allocated[type];
141 allocated[type] += samples;
142 memory_length = samples;
143
144 SPI.setMOSI(SPIRAM_MOSI_PIN);
145 SPI.setMISO(SPIRAM_MISO_PIN);
146 SPI.setSCK(SPIRAM_SCK_PIN);
147
148 SPI.begin();
149 zero(0, memory_length);
150}
151
152
153#ifdef INTERNAL_TEST

Callers 3

iFunction · 0.80
gFunction · 0.80
nFunction · 0.80

Calls 1

beginMethod · 0.45

Tested by

no test coverage detected