1. An ice-cream machine for converting a liquid or semi-liquid foodstuff, comprising: a holding tank for said foodstuff, the holding tank being a churning cylinder; a heat transfer circuit for at least one chosen from cooling and heating said foodstuff, comprising a compressor adapted to vary a thermal power of the heat transfer circuit; a stirrer positioned in the churning cylinder for churning the foodstuff into ice cream; a detection apparatus adapted to generate a parameter characteristic of said foodstuff, wherein the parameter is an electric impedance of the foodstuff; wherein the detection apparatus comprises: an electric generator for generating an electric test signal to be applied to said foodstuff for determining a variation value of the electric impedance of the foodstuff; a sensor configured for detecting said variation value of the electric impedance of the foodstuff; a measurement device connected to the sensor and configured for generating a value of the electric impedance parameter of the foodstuff from the variation value of the electric impedance of the foodstuff, wherein the variation value of the electric impedance of the foodstuff is determined by a variation in both a modulus and a phase of the electric impedance of the foodstuff; a control unit associated with said detection apparatus, comprising: a primary storage module comprising identifiers of said foodstuff and predetermined values of identification parameters corresponding to said identifiers, wherein said control unit is configured for: recognising the foodstuff by associating the generated electric impedance parameter with one of the predetermined values of the identification parameter contained in said primary storage module and thereby determining that the foodstuff is either fruit based or cream based; setting operating parameters of at least one actuator of said machine as a function of said recognized foodstuff; wherein the electric generator is configured to generate the electric test signal to include a first electric signal and a separate second electric signal in succession so that the recognising the foodstuff occurs by combining results obtained for the individual first electric and second electric signals; wherein the first electric signal has a constant amplitude and a variable frequency and the second electric signal has a variable amplitude and a constant frequency.