double get_volume() { unsigned short volume; if(SUCCEEDED(caller->GetVolume(&volume))) return convert_volume(volume); else return 1; }
gdouble pragha_backend_get_volume (PraghaBackend *backend) { PraghaBackendPrivate *priv = backend->priv; gdouble volume; g_object_get (priv->pipeline, "volume", &volume, NULL); #if HAVE_GSTREAMER_AUDIO volume = convert_volume (VOLUME_FORMAT_LINEAR, VOLUME_FORMAT_CUBIC, volume); #endif return volume; }
void pragha_backend_set_volume (PraghaBackend *backend, gdouble volume) { PraghaBackendPrivate *priv = backend->priv; volume = CLAMP (volume, 0.0, 1.0); #if HAVE_GSTREAMER_AUDIO volume = convert_volume (VOLUME_FORMAT_CUBIC, VOLUME_FORMAT_LINEAR, volume); #endif g_object_set (priv->pipeline, "volume", volume, NULL); if (pragha_preferences_get_software_mixer (priv->preferences)) pragha_preferences_set_software_volume (priv->preferences, volume); }
double convert_volume( int volume ) { return convert_volume( volume, NULL ); }
static dc_status_t dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize) { dctool_xml_output_t *output = (dctool_xml_output_t *) abstract; dc_status_t status = DC_STATUS_SUCCESS; // Initialize the sample data. sample_data_t sampledata = {0}; sampledata.nsamples = 0; sampledata.ostream = output->ostream; sampledata.units = output->units; fprintf (output->ostream, "<dive>\n<number>%u</number>\n<size>%u</size>\n", abstract->number, size); if (fingerprint) { fprintf (output->ostream, "<fingerprint>"); for (unsigned int i = 0; i < fsize; ++i) fprintf (output->ostream, "%02X", fingerprint[i]); fprintf (output->ostream, "</fingerprint>\n"); } // Parse the datetime. message ("Parsing the datetime.\n"); dc_datetime_t dt = {0}; status = dc_parser_get_datetime (parser, &dt); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the datetime."); goto cleanup; } if (dt.timezone == DC_TIMEZONE_NONE) { fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i</datetime>\n", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second); } else { fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i %+03i:%02i</datetime>\n", dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.timezone / 3600, (dt.timezone % 3600) / 60); } // Parse the divetime. message ("Parsing the divetime.\n"); unsigned int divetime = 0; status = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the divetime."); goto cleanup; } fprintf (output->ostream, "<divetime>%02u:%02u</divetime>\n", divetime / 60, divetime % 60); // Parse the maxdepth. message ("Parsing the maxdepth.\n"); double maxdepth = 0.0; status = dc_parser_get_field (parser, DC_FIELD_MAXDEPTH, 0, &maxdepth); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the maxdepth."); goto cleanup; } fprintf (output->ostream, "<maxdepth>%.2f</maxdepth>\n", convert_depth(maxdepth, output->units)); // Parse the temperature. message ("Parsing the temperature.\n"); for (unsigned int i = 0; i < 3; ++i) { dc_field_type_t fields[] = {DC_FIELD_TEMPERATURE_SURFACE, DC_FIELD_TEMPERATURE_MINIMUM, DC_FIELD_TEMPERATURE_MAXIMUM}; const char *names[] = {"surface", "minimum", "maximum"}; double temperature = 0.0; status = dc_parser_get_field (parser, fields[i], 0, &temperature); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the temperature."); goto cleanup; } if (status != DC_STATUS_UNSUPPORTED) { fprintf (output->ostream, "<temperature type=\"%s\">%.1f</temperature>\n", names[i], convert_temperature(temperature, output->units)); } } // Parse the gas mixes. message ("Parsing the gas mixes.\n"); unsigned int ngases = 0; status = dc_parser_get_field (parser, DC_FIELD_GASMIX_COUNT, 0, &ngases); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the gas mix count."); goto cleanup; } for (unsigned int i = 0; i < ngases; ++i) { dc_gasmix_t gasmix = {0}; status = dc_parser_get_field (parser, DC_FIELD_GASMIX, i, &gasmix); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the gas mix."); goto cleanup; } fprintf (output->ostream, "<gasmix>\n" " <he>%.1f</he>\n" " <o2>%.1f</o2>\n" " <n2>%.1f</n2>\n" "</gasmix>\n", gasmix.helium * 100.0, gasmix.oxygen * 100.0, gasmix.nitrogen * 100.0); } // Parse the tanks. message ("Parsing the tanks.\n"); unsigned int ntanks = 0; status = dc_parser_get_field (parser, DC_FIELD_TANK_COUNT, 0, &ntanks); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the tank count."); goto cleanup; } for (unsigned int i = 0; i < ntanks; ++i) { const char *names[] = {"none", "metric", "imperial"}; dc_tank_t tank = {0}; status = dc_parser_get_field (parser, DC_FIELD_TANK, i, &tank); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the tank."); goto cleanup; } fprintf (output->ostream, "<tank>\n"); if (tank.gasmix != DC_GASMIX_UNKNOWN) { fprintf (output->ostream, " <gasmix>%u</gasmix>\n", tank.gasmix); } if (tank.type != DC_TANKVOLUME_NONE) { fprintf (output->ostream, " <type>%s</type>\n" " <volume>%.1f</volume>\n" " <workpressure>%.2f</workpressure>\n", names[tank.type], convert_volume(tank.volume, output->units), convert_pressure(tank.workpressure, output->units)); } fprintf (output->ostream, " <beginpressure>%.2f</beginpressure>\n" " <endpressure>%.2f</endpressure>\n" "</tank>\n", convert_pressure(tank.beginpressure, output->units), convert_pressure(tank.endpressure, output->units)); } // Parse the dive mode. message ("Parsing the dive mode.\n"); dc_divemode_t divemode = DC_DIVEMODE_OC; status = dc_parser_get_field (parser, DC_FIELD_DIVEMODE, 0, &divemode); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the dive mode."); goto cleanup; } if (status != DC_STATUS_UNSUPPORTED) { const char *names[] = {"freedive", "gauge", "oc", "ccr", "scr"}; fprintf (output->ostream, "<divemode>%s</divemode>\n", names[divemode]); } // Parse the salinity. message ("Parsing the salinity.\n"); dc_salinity_t salinity = {DC_WATER_FRESH, 0.0}; status = dc_parser_get_field (parser, DC_FIELD_SALINITY, 0, &salinity); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the salinity."); goto cleanup; } if (status != DC_STATUS_UNSUPPORTED) { fprintf (output->ostream, "<salinity type=\"%u\">%.1f</salinity>\n", salinity.type, salinity.density); } // Parse the atmospheric pressure. message ("Parsing the atmospheric pressure.\n"); double atmospheric = 0.0; status = dc_parser_get_field (parser, DC_FIELD_ATMOSPHERIC, 0, &atmospheric); if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) { ERROR ("Error parsing the atmospheric pressure."); goto cleanup; } if (status != DC_STATUS_UNSUPPORTED) { fprintf (output->ostream, "<atmospheric>%.5f</atmospheric>\n", convert_pressure(atmospheric, output->units)); } // Parse the sample data. message ("Parsing the sample data.\n"); status = dc_parser_samples_foreach (parser, sample_cb, &sampledata); if (status != DC_STATUS_SUCCESS) { ERROR ("Error parsing the sample data."); goto cleanup; } cleanup: if (sampledata.nsamples) fprintf (output->ostream, "</sample>\n"); fprintf (output->ostream, "</dive>\n"); return status; }
static int dump_pattern(FILE *fff, int which, struct pattern_struct *p, int num_channels, int ch0, int ch1, int ch2) { int j,c; int pattern_break=0; int last_instrument[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, }; fprintf(fff,"\' Pattern %x\n",which); for(j=0; j < p->num_rows;j++) { /* Handle effects */ for(c=0;c<num_channels;c++) { int effect; int param; /* Check early in case we aren't outputting the */ /* channel with the break */ /* Technically some effects should go in effect */ /* globally so we should handle this better */ if (p->p[j][c].effect==0xd) pattern_break=1; // 0,1,9 // 0N 1N 2C 3C if ((c!=ch0) && (c!=ch1) && (c!=ch2)) continue; effect=p->p[j][c].effect; param=p->p[j][c].param; switch(effect) { case 0: /* arpeggio */ if (param==0) break; fprintf(fff,"* %c E %d %d\n", channel_to_channel(c,ch0,ch1,ch2), effect,param); break; case 1: /* portamento up */ fprintf(fff,"* %c E %d %d\n", channel_to_channel(c,ch0,ch1,ch2), effect,param); break; case 2: /* portamento down */ fprintf(fff,"* %c E %d %d\n", channel_to_channel(c,ch0,ch1,ch2), effect,param); break; case 4: /* Vibrato */ fprintf(fff,"* %c E %d %d\n", channel_to_channel(c,ch0,ch1,ch2), effect,param); break; case 0xd: /* early exit */ pattern_break=1; break; case 0xf: /* Change temp */ /* FIXME: warn if changing */ break; case 3: case 5: case 6: case 7: case 8: case 9: case 0xa: case 0xb: case 0xc: case 0xe: default: fprintf(stderr,"Unhandled effect %x\n", effect); } } /* Handle instrument */ for(c=0;c<num_channels;c++) { int instrument=0; if ((c!=ch0) && (c!=ch1) && (c!=ch2)) continue; instrument=p->p[j][c].instrument; /* Hardcoded match for stillalive */ if ((instrument) && (instrument!=last_instrument[c])) { last_instrument[c]=instrument; /* 1 = sine */ if (instrument==1) instrument=0; /* 2 = muted */ else if (instrument==2) instrument=6; /* 3 = triangle wave */ else if (instrument==3) instrument=10; /* 4 = bass drum */ else if (instrument==4) instrument=7; /* 5 = snare drum */ else if (instrument==5) instrument=8; /* 6 = cymbal */ else if (instrument==6) instrument=9; fprintf(fff,"* %c I %d\n", channel_to_channel(c,ch0,ch1,ch2), instrument); } } /* Handle volume */ for(c=0;c<num_channels;c++) { int volume=0; if ((c!=ch0) && (c!=ch1) && (c!=ch2)) continue; if (p->p[j][c].note) { if (p->p[j][c].note==97) volume=0x10; else volume=0x50; } if (p->p[j][c].volume) volume=p->p[j][c].volume; if (volume) { if (volume>0x50) { fprintf(stderr,"Unhandled volume %d\n", volume); continue; } //volume=(volume-0x11)/4; volume=convert_volume(volume-0x10); fprintf(fff,"* %c L %d\n", channel_to_channel(c,ch0,ch1,ch2), volume); } } fprintf(fff,"%02X ",j); /* Handle Notes */ for(c=0;c<num_channels;c++) { if ((c!=ch0) && (c!=ch1) && (c!=ch2)) continue; note_to_ym_string(fff,p->p[j][c].note,c==0); if ((p->p[j][c].note<97) && (p->p[j][c].note!=0)) { fprintf(fff," ?\t"); } else { fprintf(fff,"--\t"); } #if 0 if (p->p[j][c].instrument) { fprintf(fff,"%X",p->p[j][c].instrument); } else { fprintf(fff,"."); } if (p->p[j][c].volume) { fprintf(fff,"%02X",p->p[j][c].volume-0x10); } else { fprintf(fff,".."); } if ((p->p[j][c].effect) || (p->p[j][c].param)) { fprintf(fff,"%X%02X", p->p[j][c].effect, p->p[j][c].param); } else { fprintf(fff,"..."); } fprintf(fff," "); #endif } fprintf(fff,"\n"); if (pattern_break) break; } return 0; }